2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef IO_SCHEDULER_ROSTER_H
6 #define IO_SCHEDULER_ROSTER_H
9 #include <Notifications.h>
11 #include "IOScheduler.h"
14 // I/O scheduler notifications
15 #define IO_SCHEDULER_MONITOR '_io_'
16 #define IO_SCHEDULER_ADDED 0x01
17 #define IO_SCHEDULER_REMOVED 0x02
18 #define IO_SCHEDULER_REQUEST_SCHEDULED 0x04
19 #define IO_SCHEDULER_REQUEST_FINISHED 0x08
20 #define IO_SCHEDULER_OPERATION_STARTED 0x10
21 #define IO_SCHEDULER_OPERATION_FINISHED 0x20
25 typedef DoublyLinkedList
<IOScheduler
> IOSchedulerList
;
28 class IOSchedulerRoster
{
31 static IOSchedulerRoster
* Default() { return &sDefaultInstance
; }
33 bool Lock() { return mutex_lock(&fLock
) == B_OK
; }
34 void Unlock() { mutex_unlock(&fLock
); }
36 const IOSchedulerList
& SchedulerList() const
37 { return fSchedulers
; }
38 // caller must keep the roster locked,
39 // while accessing the list
41 void AddScheduler(IOScheduler
* scheduler
);
42 void RemoveScheduler(IOScheduler
* scheduler
);
44 void Notify(uint32 eventCode
,
45 const IOScheduler
* scheduler
,
46 IORequest
* request
= NULL
,
47 IOOperation
* operation
= NULL
);
58 IOSchedulerList fSchedulers
;
59 DefaultNotificationService fNotificationService
;
60 char fEventBuffer
[256];
62 static IOSchedulerRoster sDefaultInstance
;
66 #endif // IO_SCHEDULER_ROSTER_H