Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
23
Src/nu/ThreadQueue.h
Normal file
23
Src/nu/ThreadQueue.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include "RingBuffer.h"
|
||||
#include <semaphore.h>
|
||||
|
||||
class ThreadQueue
|
||||
{
|
||||
public:
|
||||
ThreadQueue();
|
||||
~ThreadQueue();
|
||||
void Queue(const void *);
|
||||
// Get() blocks until there's something in the queue
|
||||
void *Get();
|
||||
// return value is same as sem_wait
|
||||
// delay is in nanoseconds
|
||||
int Wait(long delay, void **val);
|
||||
// kind of like sem_trywait
|
||||
int Try(void **val);
|
||||
private:
|
||||
// TODO: need to use something safer than RingBuffer, preferably a lock-free linked list so we can grow unlimited
|
||||
RingBuffer buffer;
|
||||
sem_t event;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue