btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / system / kernel / device_manager / IOSchedulerRoster.h
blobf43f9afc05ddf50ebb2ff916fac9b41601acc81d
1 /*
2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
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 {
29 public:
30 static void Init();
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);
49 int32 NextID();
51 private:
52 IOSchedulerRoster();
53 ~IOSchedulerRoster();
55 private:
56 mutex fLock;
57 int32 fNextID;
58 IOSchedulerList fSchedulers;
59 DefaultNotificationService fNotificationService;
60 char fEventBuffer[256];
62 static IOSchedulerRoster sDefaultInstance;
66 #endif // IO_SCHEDULER_ROSTER_H