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