f6e4cbb952
definitions). * Minor cleanup here and there. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22577 a95241bf-73f2-0310-859d-f6bbb57e9c96
85 lines
1.7 KiB
C++
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
|