JobQueue: fixed leak, notification, added Pop() variant.

* Was leaking fQueuedJobs on destruction.
* fHaveRunnableJobSem implementation was not completed; it was never
  released.
* Added Pop() variant that is a bit more flexible, and allows for a
  timeout as well as waiting even when the queue is empty, and can
  return a status code.
This commit is contained in:
Axel Dörfler
2015-06-03 16:22:44 +02:00
parent 3375ee66bc
commit 6ff95509c2
2 changed files with 51 additions and 18 deletions
+5 -1
View File
@@ -30,8 +30,12 @@ public:
// gives up ownership
BJob* Pop();
status_t Pop(bigtime_t timeout, bool returnWhenEmpty,
BJob** _job);
// caller owns job
size_t CountJobs() const;
void Close();
private:
@@ -49,7 +53,7 @@ private:
void _RequeueDependantJobsOf(BJob* job);
void _RemoveDependantJobsOf(BJob* job);
BLocker fLock;
mutable BLocker fLock;
uint32 fNextTicketNumber;
JobPriorityQueue* fQueuedJobs;
sem_id fHaveRunnableJobSem;