Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct ThreadOperationStruct _THREADIO;
- int main(int argc, char** argv)
- {
- // threads get created here...
- }
- void DecompressLogFile::Wait()
- {
- while (!_THREADIO.EndEvent)
- {
- pthread_mutex_lock(&Lock);
- size_t QueueSize = _THREADIO.DecompressLogQueue.size();
- if (!QueueSize)
- {
- // Prevent further thread execution
- fprintf(stdout, "DecompressLogFile() thread sleeping...n");
- pthread_mutex_unlock(&Lock);
- pthread_cond_wait(&_THREADIO.DecompressQueueNotify, &Lock);
- } else {
- thread_mutex_lock(&Lock);
- fprintf(stdout, "Processing compressed log files. Queue size is now %lun", QueueSize);
- /*
- * Async tasks need to go here...
- */
- //BZIP2_DecompressFile();
- _THREADIO.DecompressLogQueue.pop();
- }
- }
- fprintf(stdout, "Wait() endn");
- }
- _THREADIO.DecompressLogQueue.push(NewLog);
- pthread_cond_signal(&_THREADIO.DecompressQueueNotify);
- struct ThreadOperationStruct
- {
- std::queue<std::string> DecompressLogQueue;
- std::queue<std::string> ProcessLogQueue;
- void NotifyDecompressThread()
- {
- fprintf(stdout, "notifying..n");
- pthread_cond_signal(&this->DecompressQueueNotify);
- }
- pthread_cond_t DecompressQueueNotify;
- pthread_cond_t ProcessQueueNotify;
- bool EndEvent = false;
- };
- extern ThreadOperationStruct _THREADIO;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement