haiku/headers/private/app/LooperList.h
Axel Dörfler f6e4cbb952 * Rewrote BeBuild.h which had "a few" consequences (got rid of all those class
definitions).
* Minor cleanup here and there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22577 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-10-15 20:13:55 +00:00

85 lines
1.7 KiB
C++

/*
* Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Erik Jaesler (erik@cgsoftware.com)
*/
#ifndef LOOPERLIST_H
#define LOOPERLIST_H
#include <Locker.h>
#include <OS.h>
#include <SupportDefs.h>
#include <vector>
class BList;
class BLooper;
namespace BPrivate {
class BLooperList {
public:
BLooperList();
bool Lock();
void Unlock();
bool IsLocked();
void AddLooper(BLooper* l);
bool IsLooperValid(const BLooper* l);
bool RemoveLooper(BLooper* l);
void GetLooperList(BList* list);
int32 CountLoopers();
BLooper* LooperAt(int32 index);
BLooper* LooperForThread(thread_id tid);
BLooper* LooperForName(const char* name);
BLooper* LooperForPort(port_id port);
private:
struct LooperData {
LooperData();
LooperData(BLooper* looper);
LooperData(const LooperData& rhs);
LooperData& operator=(const LooperData& rhs);
BLooper* looper;
};
static bool EmptySlotPred(LooperData& Data);
struct FindLooperPred {
FindLooperPred(const BLooper* loop) : looper(loop) {;}
bool operator()(LooperData& Data);
const BLooper* looper;
};
struct FindThreadPred {
FindThreadPred(thread_id tid) : thread(tid) {;}
bool operator()(LooperData& Data);
thread_id thread;
};
struct FindNamePred {
FindNamePred(const char* n) : name(n) {;}
bool operator()(LooperData& Data);
const char* name;
};
struct FindPortPred {
FindPortPred(port_id pid) : port(pid) {;}
bool operator()(LooperData& Data);
port_id port;
};
void AssertLocked();
BLocker fLock;
std::vector<LooperData> fData;
};
extern BLooperList gLooperList;
} // namespace BPrivate
#endif // LOOPERLIST_H