Alive thread implemented

This commit is contained in:
2026-04-11 09:50:59 +02:00
parent 8e5381fda2
commit 52aa0cac10
10 changed files with 215 additions and 31 deletions

View File

@@ -23,6 +23,11 @@ ShmQueue::ShmQueue(Shm *shm, ShmSlot slot, bool owner)
_queue_sem = shm->sem(buf, owner);
}
void ShmQueue::takeOwnership()
{
_queue_sem->takeOwnership();
}
ShmQueue::~ShmQueue()
{
if (_owner) {
@@ -83,15 +88,14 @@ void ShmQueue::enqueue(int cmd)
enqueue(cmd, s);
}
bool ShmQueue::dequeue(int &cmd, std::string &json_data, bool wait)
bool ShmQueue::dequeue(int &cmd, std::string &json_data, int wait_ms)
{
if (wait) {
_queue_sem->wait();
} else {
if (!_queue_sem->trywait()) {
return false;
}
bool something_came = _queue_sem->wait(wait_ms);
if (!something_came) {
return false;
}
_shm->lock();
ShmPlace item_place = _queue->first;