2 * Copyright 2011-2015, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 #ifndef _SUPPORT_PRIVATE_JOB_QUEUE_H_
6 #define _SUPPORT_PRIVATE_JOB_QUEUE_H_
10 #include <SupportDefs.h>
15 namespace BSupportKit
{
20 class JobQueue
: private BJobStateListener
{
25 status_t
InitCheck() const;
27 status_t
AddJob(BJob
* job
);
29 status_t
RemoveJob(BJob
* job
);
33 status_t
Pop(bigtime_t timeout
, bool returnWhenEmpty
,
37 size_t CountJobs() const;
43 virtual void JobSucceeded(BJob
* job
);
44 virtual void JobFailed(BJob
* job
);
47 struct JobPriorityLess
;
48 class JobPriorityQueue
;
53 void _RequeueDependantJobsOf(BJob
* job
);
54 void _RemoveDependantJobsOf(BJob
* job
);
56 mutable BLocker fLock
;
57 uint32 fNextTicketNumber
;
58 JobPriorityQueue
* fQueuedJobs
;
59 sem_id fHaveRunnableJobSem
;
65 } // namespace BPrivate
67 } // namespace BSupportKit
70 #endif // _SUPPORT_PRIVATE_JOB_QUEUE_H_