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:
parent
85d2badf00
commit
f71be99bd9
@ -32,6 +32,8 @@ public:
|
||||
|
||||
BJob* PopRunnableJob();
|
||||
|
||||
status_t Process(bool failIfCanceledOnly = false);
|
||||
|
||||
protected:
|
||||
status_t QueueJob(BJob* job);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user