Update libhv_bindings.hpp

This commit is contained in:
blueloveTH 2025-01-23 16:53:13 +08:00
parent 24c0ed5138
commit c1adf77afd

View File

@ -15,6 +15,7 @@ py_Type libhv_register_WebSocketClient(py_GlobalRef mod);
#include <deque>
#include <atomic>
#include <thread>
template <typename T>
class libhv_MQ {
@ -25,7 +26,7 @@ private:
public:
void push(T msg) {
while(lock.exchange(true)) {
hv_delay(1);
std::this_thread::yield();
}
queue.push_back(msg);
lock.store(false);
@ -33,7 +34,7 @@ public:
bool pop(T* msg) {
while(lock.exchange(true)) {
hv_delay(1);
std::this_thread::yield();
}
if(queue.empty()) {
lock.store(false);