mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
Update libhv_bindings.hpp
This commit is contained in:
parent
24c0ed5138
commit
c1adf77afd
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user