* Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36213 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+36
-26
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2010, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Erik Jaesler ([email protected])
|
* Erik Jaesler ([email protected])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! Maintains a global list of all loopers in a given team.
|
//! Maintains a global list of all loopers in a given team.
|
||||||
|
|
||||||
|
|
||||||
@@ -58,10 +59,11 @@ BLooperList::IsLocked()
|
|||||||
void
|
void
|
||||||
BLooperList::AddLooper(BLooper* looper)
|
BLooperList::AddLooper(BLooper* looper)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
if (!IsLooperValid(looper)) {
|
if (!IsLooperValid(looper)) {
|
||||||
LooperDataIterator i = find_if(fData.begin(), fData.end(), EmptySlotPred);
|
LooperDataIterator i
|
||||||
|
= find_if(fData.begin(), fData.end(), EmptySlotPred);
|
||||||
if (i == fData.end()) {
|
if (i == fData.end()) {
|
||||||
fData.push_back(LooperData(looper));
|
fData.push_back(LooperData(looper));
|
||||||
looper->Lock();
|
looper->Lock();
|
||||||
@@ -76,7 +78,7 @@ BLooperList::AddLooper(BLooper* looper)
|
|||||||
bool
|
bool
|
||||||
BLooperList::IsLooperValid(const BLooper* looper)
|
BLooperList::IsLooperValid(const BLooper* looper)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
return find_if(fData.begin(), fData.end(),
|
return find_if(fData.begin(), fData.end(),
|
||||||
@@ -87,7 +89,7 @@ BLooperList::IsLooperValid(const BLooper* looper)
|
|||||||
bool
|
bool
|
||||||
BLooperList::RemoveLooper(BLooper* looper)
|
BLooperList::RemoveLooper(BLooper* looper)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
LooperDataIterator i = find_if(fData.begin(), fData.end(),
|
LooperDataIterator i = find_if(fData.begin(), fData.end(),
|
||||||
@@ -104,7 +106,7 @@ BLooperList::RemoveLooper(BLooper* looper)
|
|||||||
void
|
void
|
||||||
BLooperList::GetLooperList(BList* list)
|
BLooperList::GetLooperList(BList* list)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
for (uint32 i = 0; i < fData.size(); ++i) {
|
for (uint32 i = 0; i < fData.size(); ++i) {
|
||||||
@@ -117,7 +119,7 @@ BLooperList::GetLooperList(BList* list)
|
|||||||
int32
|
int32
|
||||||
BLooperList::CountLoopers()
|
BLooperList::CountLoopers()
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
return (int32)fData.size();
|
return (int32)fData.size();
|
||||||
}
|
}
|
||||||
@@ -126,7 +128,7 @@ BLooperList::CountLoopers()
|
|||||||
BLooper*
|
BLooper*
|
||||||
BLooperList::LooperAt(int32 index)
|
BLooperList::LooperAt(int32 index)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
BLooper* looper = NULL;
|
BLooper* looper = NULL;
|
||||||
@@ -140,10 +142,12 @@ BLooperList::LooperAt(int32 index)
|
|||||||
BLooper*
|
BLooper*
|
||||||
BLooperList::LooperForThread(thread_id thread)
|
BLooperList::LooperForThread(thread_id thread)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
BLooper* looper = NULL;
|
BLooper* looper = NULL;
|
||||||
LooperDataIterator i = find_if(fData.begin(), fData.end(), FindThreadPred(thread));
|
LooperDataIterator i
|
||||||
|
= find_if(fData.begin(), fData.end(), FindThreadPred(thread));
|
||||||
if (i != fData.end())
|
if (i != fData.end())
|
||||||
looper = i->looper;
|
looper = i->looper;
|
||||||
|
|
||||||
@@ -154,10 +158,12 @@ BLooperList::LooperForThread(thread_id thread)
|
|||||||
BLooper*
|
BLooper*
|
||||||
BLooperList::LooperForName(const char* name)
|
BLooperList::LooperForName(const char* name)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
BLooper* looper = NULL;
|
BLooper* looper = NULL;
|
||||||
LooperDataIterator i = find_if(fData.begin(), fData.end(), FindNamePred(name));
|
LooperDataIterator i
|
||||||
|
= find_if(fData.begin(), fData.end(), FindNamePred(name));
|
||||||
if (i != fData.end())
|
if (i != fData.end())
|
||||||
looper = i->looper;
|
looper = i->looper;
|
||||||
|
|
||||||
@@ -168,10 +174,12 @@ BLooperList::LooperForName(const char* name)
|
|||||||
BLooper*
|
BLooper*
|
||||||
BLooperList::LooperForPort(port_id port)
|
BLooperList::LooperForPort(port_id port)
|
||||||
{
|
{
|
||||||
BAutolock Listlock(fLock);
|
BAutolock locker(fLock);
|
||||||
AssertLocked();
|
AssertLocked();
|
||||||
|
|
||||||
BLooper* looper = NULL;
|
BLooper* looper = NULL;
|
||||||
LooperDataIterator i = find_if(fData.begin(), fData.end(), FindPortPred(port));
|
LooperDataIterator i
|
||||||
|
= find_if(fData.begin(), fData.end(), FindPortPred(port));
|
||||||
if (i != fData.end())
|
if (i != fData.end())
|
||||||
looper = i->looper;
|
looper = i->looper;
|
||||||
|
|
||||||
@@ -180,9 +188,9 @@ BLooperList::LooperForPort(port_id port)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BLooperList::EmptySlotPred(LooperData& Data)
|
BLooperList::EmptySlotPred(LooperData& data)
|
||||||
{
|
{
|
||||||
return Data.looper == NULL;
|
return data.looper == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -198,13 +206,15 @@ BLooperList::AssertLocked()
|
|||||||
|
|
||||||
|
|
||||||
BLooperList::LooperData::LooperData()
|
BLooperList::LooperData::LooperData()
|
||||||
: looper(NULL)
|
:
|
||||||
|
looper(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BLooperList::LooperData::LooperData(BLooper* looper)
|
BLooperList::LooperData::LooperData(BLooper* looper)
|
||||||
: looper(looper)
|
:
|
||||||
|
looper(looper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,30 +236,30 @@ BLooperList::LooperData::operator=(const LooperData& other)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BLooperList::FindLooperPred::operator()(BLooperList::LooperData& Data)
|
BLooperList::FindLooperPred::operator()(BLooperList::LooperData& data)
|
||||||
{
|
{
|
||||||
return Data.looper && looper == Data.looper;
|
return data.looper && looper == data.looper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BLooperList::FindThreadPred::operator()(LooperData& Data)
|
BLooperList::FindThreadPred::operator()(LooperData& data)
|
||||||
{
|
{
|
||||||
return Data.looper && thread == Data.looper->Thread();
|
return data.looper && thread == data.looper->Thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BLooperList::FindNamePred::operator()(LooperData& Data)
|
BLooperList::FindNamePred::operator()(LooperData& data)
|
||||||
{
|
{
|
||||||
return Data.looper && !strcmp(name, Data.looper->Name());
|
return data.looper && !strcmp(name, data.looper->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BLooperList::FindPortPred::operator()(LooperData& Data)
|
BLooperList::FindPortPred::operator()(LooperData& data)
|
||||||
{
|
{
|
||||||
return Data.looper && port == _get_looper_port_(Data.looper);
|
return data.looper && port == _get_looper_port_(data.looper);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
Reference in New Issue
Block a user