BRequest: Add Process()

The method creates the initial jobs for the request and processes the
jobs from the job queue until empty or an error occurs.
This commit is contained in:
Ingo Weinhold 2013-04-20 13:26:34 +02:00
parent 85d2badf00
commit f71be99bd9
2 changed files with 26 additions and 0 deletions

View File

@ -32,6 +32,8 @@ public:
BJob* PopRunnableJob();
status_t Process(bool failIfCanceledOnly = false);
protected:
status_t QueueJob(BJob* job);

View File

@ -49,6 +49,30 @@ BRequest::PopRunnableJob()
}
status_t
BRequest::Process(bool failIfCanceledOnly)
{
status_t error = InitCheck();
if (error != B_OK)
return error;
error = CreateInitialJobs();
if (error != B_OK)
return error;
while (BJob* job = PopRunnableJob()) {
error = job->Run();
delete job;
if (error != B_OK) {
if (!failIfCanceledOnly || error == B_CANCELED)
return error;
}
}
return B_OK;
}
status_t
BRequest::QueueJob(BJob* job)
{