mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-15 00:56:22 +00:00
updated to 0.3.1
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
CBlockingQueue::CBlockingQueue(size_t capacity){
|
||||
this->capacity=capacity;
|
||||
overflowCallback=NULL;
|
||||
init_lock(lock);
|
||||
init_mutex(mutex);
|
||||
}
|
||||
@@ -29,7 +30,12 @@ void CBlockingQueue::Put(void *thing){
|
||||
}
|
||||
queue.push_back(thing);
|
||||
while(queue.size()>capacity){
|
||||
queue.pop_front();
|
||||
if(overflowCallback){
|
||||
overflowCallback(queue.front());
|
||||
queue.pop_front();
|
||||
}else{
|
||||
abort();
|
||||
}
|
||||
}
|
||||
unlock_mutex(mutex);
|
||||
}
|
||||
@@ -72,3 +78,7 @@ void CBlockingQueue::PrepareDealloc(){
|
||||
unlock_mutex(mutex);
|
||||
}
|
||||
|
||||
|
||||
void CBlockingQueue::SetOverflowCallback(void (*overflowCallback)(void *)){
|
||||
this->overflowCallback=overflowCallback;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user