mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +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 <deque>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class libhv_MQ {
|
class libhv_MQ {
|
||||||
@ -25,7 +26,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
void push(T msg) {
|
void push(T msg) {
|
||||||
while(lock.exchange(true)) {
|
while(lock.exchange(true)) {
|
||||||
hv_delay(1);
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
queue.push_back(msg);
|
queue.push_back(msg);
|
||||||
lock.store(false);
|
lock.store(false);
|
||||||
@ -33,7 +34,7 @@ public:
|
|||||||
|
|
||||||
bool pop(T* msg) {
|
bool pop(T* msg) {
|
||||||
while(lock.exchange(true)) {
|
while(lock.exchange(true)) {
|
||||||
hv_delay(1);
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
if(queue.empty()) {
|
if(queue.empty()) {
|
||||||
lock.store(false);
|
lock.store(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user