1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-11 16:49:52 +01:00
libtgvoip/BlockingQueue.h

40 lines
834 B
C
Raw Normal View History

2017-02-02 17:24:40 +01:00
//
// libtgvoip is free and unencumbered public domain software.
// For more information, see http://unlicense.org or the UNLICENSE file
// you should have received with this source code distribution.
//
#ifndef LIBTGVOIP_BLOCKINGQUEUE_H
#define LIBTGVOIP_BLOCKINGQUEUE_H
#include <stdlib.h>
#include <list>
#include "threading.h"
using namespace std;
namespace tgvoip{
class BlockingQueue{
2017-02-02 17:24:40 +01:00
public:
BlockingQueue(size_t capacity);
~BlockingQueue();
2017-02-02 17:24:40 +01:00
void Put(void* thing);
void* GetBlocking();
void* Get();
unsigned int Size();
void PrepareDealloc();
2017-03-30 16:06:59 +02:00
void SetOverflowCallback(void (*overflowCallback)(void*));
2017-02-02 17:24:40 +01:00
private:
void* GetInternal();
list<void*> queue;
size_t capacity;
//tgvoip_lock_t lock;
Semaphore semaphore;
2017-02-02 17:24:40 +01:00
tgvoip_mutex_t mutex;
2017-03-30 16:06:59 +02:00
void (*overflowCallback)(void*);
2017-02-02 17:24:40 +01:00
};
}
2017-02-02 17:24:40 +01:00
#endif //LIBTGVOIP_BLOCKINGQUEUE_H