7d7ed9bf4b
* drop 'Haiku' namespace * rename 'Package' namespace to 'BPackageKit' * renamed all public classes to begin with a 'B' * renamed BPackageKit::Roster to BPackageKit::BPackageRoster to not clash with the BRoster from the application kit. * fix some instances of public headers including private ones Some functional changes, too: * JobQueue now removes and deletes dependants of failed jobs automatically * JobQueue supports waiting for jobs to become runnable * added a couple of InitCheck() methods where they make sense and invoke those in users of these classes git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40287 a95241bf-73f2-0310-859d-f6bbb57e9c96
67 lines
1.2 KiB
C++
67 lines
1.2 KiB
C++
/*
|
|
* Copyright 2011, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _PACKAGE__PRIVATE__JOB_QUEUE_H_
|
|
#define _PACKAGE__PRIVATE__JOB_QUEUE_H_
|
|
|
|
|
|
#include <Locker.h>
|
|
#include <SupportDefs.h>
|
|
|
|
#include <package/Job.h>
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
class JobQueue : private BJobStateListener {
|
|
public:
|
|
JobQueue();
|
|
virtual ~JobQueue();
|
|
|
|
status_t InitCheck() const;
|
|
|
|
status_t AddJob(BJob* job);
|
|
// takes ownership
|
|
status_t RemoveJob(BJob* job);
|
|
// gives up ownership
|
|
|
|
BJob* Pop();
|
|
// caller owns job
|
|
|
|
void Close();
|
|
|
|
private:
|
|
// BJobStateListener
|
|
virtual void JobSucceeded(BJob* job);
|
|
virtual void JobFailed(BJob* job);
|
|
|
|
private:
|
|
struct JobPriorityLess;
|
|
class JobPriorityQueue;
|
|
|
|
private:
|
|
status_t _Init();
|
|
|
|
void _RequeueDependantJobsOf(BJob* job);
|
|
void _RemoveDependantJobsOf(BJob* job);
|
|
|
|
BLocker fLock;
|
|
uint32 fNextTicketNumber;
|
|
JobPriorityQueue* fQueuedJobs;
|
|
sem_id fHaveRunnableJobSem;
|
|
|
|
status_t fInitStatus;
|
|
};
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // _PACKAGE__PRIVATE__JOB_QUEUE_H_
|