btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / servers / package / JobQueue.h
bloba878d6a018207eeece39fc7a2069d009a9404736
1 /*
2 * Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
7 */
8 #ifndef JOB_QUEUE_H
9 #define JOB_QUEUE_H
12 #include <pthread.h>
14 #include "Job.h"
17 class JobQueue {
18 public:
19 class Filter;
21 public:
22 JobQueue();
23 ~JobQueue();
25 status_t Init();
26 void Close();
28 bool QueueJob(Job* job);
29 // acquires a reference, if successful
30 Job* DequeueJob();
31 // returns a reference
33 void DeleteJobs(Filter* filter);
35 private:
36 typedef DoublyLinkedList<Job> JobList;
38 private:
39 pthread_mutex_t fMutex;
40 pthread_cond_t fNewJobCondition;
41 bool fMutexInitialized;
42 bool fNewJobConditionInitialized;
43 JobList fJobs;
44 bool fClosed;
48 class JobQueue::Filter {
49 public:
50 virtual ~Filter();
52 virtual bool FilterJob(Job* job) = 0;
56 #endif // JOB_QUEUE_H