2007-01-26 15:11:33 +03:00
|
|
|
/*
|
2011-10-30 01:04:22 +04:00
|
|
|
* Copyright 2001-2011, Haiku.
|
2007-01-26 15:11:33 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Erik Jaesler (erik@cgsoftware.com)
|
|
|
|
*/
|
2011-10-30 01:04:22 +04:00
|
|
|
#ifndef LOOPER_LIST_H
|
|
|
|
#define LOOPER_LIST_H
|
2002-07-15 20:04:06 +04:00
|
|
|
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
#include <vector>
|
|
|
|
|
2002-07-15 20:04:06 +04:00
|
|
|
#include <Locker.h>
|
|
|
|
#include <OS.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
class BList;
|
2002-07-15 20:04:06 +04:00
|
|
|
class BLooper;
|
|
|
|
|
2007-01-26 15:11:33 +03:00
|
|
|
|
2002-07-15 20:04:06 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2007-01-26 15:11:33 +03:00
|
|
|
class BLooperList {
|
2011-10-30 01:04:22 +04:00
|
|
|
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);
|
|
|
|
|
2011-10-30 01:17:59 +04:00
|
|
|
void InitAfterFork();
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
private:
|
|
|
|
struct LooperData {
|
|
|
|
LooperData();
|
|
|
|
LooperData(BLooper* looper);
|
|
|
|
LooperData(const LooperData& rhs);
|
|
|
|
LooperData& operator=(const LooperData& rhs);
|
|
|
|
|
|
|
|
BLooper* looper;
|
|
|
|
};
|
2014-01-11 00:06:29 +04:00
|
|
|
typedef std::vector<BLooperList::LooperData>::iterator LooperDataIterator;
|
2011-10-30 01:04:22 +04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool EmptySlotPred(LooperData& Data);
|
|
|
|
void AssertLocked();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BLocker fLock;
|
|
|
|
std::vector<LooperData> fData;
|
2002-07-15 20:04:06 +04:00
|
|
|
};
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2007-01-26 15:11:33 +03:00
|
|
|
extern BLooperList gLooperList;
|
2002-07-15 20:04:06 +04:00
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2007-01-26 15:11:33 +03:00
|
|
|
} // namespace BPrivate
|
2002-07-15 20:04:06 +04:00
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
|
|
|
#endif // LOOPER_LIST_H
|