vfs: check userland buffers before reading them.
[haiku.git] / src / servers / registrar / MessageRunnerManager.h
blobc40500e8190416b4c9d1333b0163d9def59c2f4c
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2001-2002, OpenBeOS
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
22 // File Name: MessageRunnerManager.h
23 // Author: Ingo Weinhold (bonefish@users.sf.net)
24 // Description: Manages the registrar side "shadows" of BMessageRunners.
25 //------------------------------------------------------------------------------
27 #ifndef MESSAGE_RUNNER_MANAGER_H
28 #define MESSAGE_RUNNER_MANAGER_H
30 #include <List.h>
31 #include <Locker.h>
33 class BMessage;
34 class EventQueue;
36 class MessageRunnerManager {
37 public:
38 MessageRunnerManager(EventQueue *eventQueue);
39 virtual ~MessageRunnerManager();
41 void HandleRegisterRunner(BMessage *request);
42 void HandleUnregisterRunner(BMessage *request);
43 void HandleSetRunnerParams(BMessage *request);
44 void HandleGetRunnerInfo(BMessage *request);
46 bool Lock();
47 void Unlock();
49 private:
50 class RunnerEvent;
51 struct RunnerInfo;
52 friend class RunnerEvent;
54 private:
55 bool _AddInfo(RunnerInfo *info);
56 bool _RemoveInfo(RunnerInfo *info);
57 RunnerInfo *_RemoveInfo(int32 index);
58 RunnerInfo *_RemoveInfoWithToken(int32 token);
59 bool _DeleteInfo(RunnerInfo *info, bool eventRemoved);
61 int32 _CountInfos() const;
63 RunnerInfo *_InfoAt(int32 index) const;
64 RunnerInfo *_InfoForToken(int32 token) const;
66 bool _HasInfo(RunnerInfo *info) const;
68 int32 _IndexOf(RunnerInfo *info) const;
69 int32 _IndexOfToken(int32 token) const;
71 bool _DoEvent(RunnerInfo *info);
72 bool _ScheduleEvent(RunnerInfo *info);
74 int32 _NextToken();
76 private:
77 BList fRunnerInfos;
78 BLocker fLock;
79 EventQueue *fEventQueue;
80 int32 fNextToken;
83 #endif // MESSAGE_RUNNER_MANAGER_H