Implemented job related functions.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4138 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fe05b0ac95
commit
68f12c0221
@ -109,12 +109,10 @@ void partition_modified(partition_id partitionID);
|
||||
disk_system_id find_disk_system(const char *name);
|
||||
|
||||
// jobs
|
||||
bool set_disk_device_job_status(disk_job_id job, uint32 status);
|
||||
// probably not needed
|
||||
uint32 get_disk_device_job_status(disk_job_id job);
|
||||
bool update_disk_device_job_progress(disk_job_id job, float progress);
|
||||
bool update_disk_device_job_extra_progress(disk_job_id job, const char *info);
|
||||
uint32 update_disk_device_job_interrupt_properties(disk_job_id job,
|
||||
bool update_disk_device_job_progress(disk_job_id jobID, float progress);
|
||||
bool update_disk_device_job_extra_progress(disk_job_id jobID,
|
||||
const char *info);
|
||||
uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID,
|
||||
uint32 interruptProperties);
|
||||
// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "disk_device_manager.h"
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceJob.h"
|
||||
#include "KDiskDeviceJobQueue.h"
|
||||
#include "KDiskDeviceManager.h"
|
||||
#include "KDiskDeviceUtils.h"
|
||||
#include "KDiskSystem.h"
|
||||
@ -190,3 +192,69 @@ find_disk_system(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// update_disk_device_job_progress
|
||||
bool
|
||||
update_disk_device_job_progress(disk_job_id jobID, float progress)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (ManagerLocker locker = manager) {
|
||||
if (KDiskDeviceJob *job = manager->FindJob(jobID)) {
|
||||
job->UpdateProgress(progress);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// update_disk_device_job_extra_progress
|
||||
bool
|
||||
update_disk_device_job_extra_progress(disk_job_id jobID, const char *info)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (ManagerLocker locker = manager) {
|
||||
if (KDiskDeviceJob *job = manager->FindJob(jobID)) {
|
||||
job->UpdateExtraProgress(info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// update_disk_device_job_interrupt_properties
|
||||
uint32
|
||||
update_disk_device_job_interrupt_properties(disk_job_id jobID,
|
||||
uint32 interruptProperties)
|
||||
{
|
||||
bool paused = false;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
do {
|
||||
sem_id pauseSemaphore = -1;
|
||||
if (ManagerLocker locker = manager) {
|
||||
// get the job and the respective job queue
|
||||
if (KDiskDeviceJob *job = manager->FindJob(jobID)) {
|
||||
if (KDiskDeviceJobQueue *jobQueue = job->JobQueue()) {
|
||||
// terminate if canceled.
|
||||
if (jobQueue->IsCanceled()) {
|
||||
if (jobQueue->ShallReverse())
|
||||
return B_DISK_DEVICE_JOB_REVERSE;
|
||||
return B_DISK_DEVICE_JOB_CANCEL;
|
||||
}
|
||||
// set the new interrupt properties only when not
|
||||
// requested to pause
|
||||
if (jobQueue->IsPauseRequested())
|
||||
pauseSemaphore = jobQueue->ReadyToPause();
|
||||
else
|
||||
job->SetInterruptProperties(interruptProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
// pause, if requested; redo the loop then
|
||||
paused = (pauseSemaphore >= 0);
|
||||
if (paused) {
|
||||
acquire_sem(pauseSemaphore);
|
||||
pauseSemaphore = -1;
|
||||
}
|
||||
} while (paused);
|
||||
return B_DISK_DEVICE_JOB_CONTINUE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user