This commit is contained in:
blueloveTH 2025-06-05 21:18:47 +08:00
parent 785bb6841e
commit 6b80817a98
3 changed files with 6 additions and 7 deletions

View File

@ -4,6 +4,8 @@
#include "http/HttpMessage.h"
#include "base/hplatform.h"
#include "pocketpy/common/name.h"
extern "C" void pk__add_module_libhv();
void libhv_HttpRequest_create(py_OutRef out, HttpRequestPtr ptr);

View File

@ -3,9 +3,6 @@
#include "pocketpy/pocketpy.h"
#include "http/client/WebSocketClient.h"
extern py_Name __new__;
extern py_Name __init__;
struct libhv_WebSocketClient {
hv::WebSocketClient ws;

View File

@ -14,7 +14,7 @@ typedef struct NameBucket {
static struct {
NameBucket* table[0x10000];
atomic_bool lock;
atomic_flag lock;
} pk_string_table;
#define MAGIC_METHOD(x) py_Name x;
@ -40,7 +40,7 @@ void pk_names_finalize() {
}
py_Name py_namev(c11_sv name) {
while(atomic_exchange(&pk_string_table.lock, true)) {
while(atomic_flag_test_and_set(&pk_string_table.lock)) {
// busy-wait until the lock is released
}
uint64_t hash = c11_sv__hash(name);
@ -58,7 +58,7 @@ py_Name py_namev(c11_sv name) {
p = p->next;
}
if(found) {
atomic_store(&pk_string_table.lock, false);
atomic_flag_clear(&pk_string_table.lock);
return (py_Name)p;
}
@ -75,7 +75,7 @@ py_Name py_namev(c11_sv name) {
assert(prev->next == NULL);
prev->next = bucket;
}
atomic_store(&pk_string_table.lock, false);
atomic_flag_clear(&pk_string_table.lock);
return (py_Name)bucket;
}