laforge
/
openbts-osmo
Archived
1
0
Fork 0

Implement another flavor of TransactionTable::find() with mobile ID and service type.

This commit is contained in:
Alexander Chemeris 2010-09-09 18:24:57 +04:00
parent aeedcc50b6
commit bf4c962d41
2 changed files with 38 additions and 0 deletions

View File

@ -386,6 +386,34 @@ bool TransactionTable::find(const L3MobileIdentity& mobileID, TransactionEntry&
return foundIt;
}
bool TransactionTable::find(const L3MobileIdentity& mobileID, GSM::L3CMServiceType serviceType, TransactionEntry& target)
{
// Yes, it's linear time.
// Even in a 6-ARFCN system, it should rarely be more than a dozen entries.
// Since clearDeadEntries is also linear, do that here, too.
// Brute force search.
bool foundIt = false;
mLock.lock();
clearDeadEntries();
TransactionMap::const_iterator itr = mTable.begin();
while (itr!=mTable.end()) {
const TransactionEntry& transaction = itr->second;
if (transaction.subscriber()==mobileID && transaction.service()==serviceType) {
// No need to check dead(), since we just cleared the table.
foundIt = true;
target = transaction;
break;
}
++itr;
}
mLock.unlock();
return foundIt;
}
size_t TransactionTable::size()
{
return mTable.size();

View File

@ -679,6 +679,16 @@ class TransactionTable {
*/
bool find(const GSM::L3MobileIdentity& mobileID, TransactionEntry& target);
/**
Find an entry by its mobile ID and service type.
Also clears dead entries during search.
@param mobileID The mobile at to search for.
@param serviceType Service type we're looking for.
@param target A TransactionEntry to accept the found record.
@return true is the mobile ID was found.
*/
bool find(const GSM::L3MobileIdentity& mobileID, GSM::L3CMServiceType serviceType, TransactionEntry& target);
/**
Remove "dead" entries from the table.
A "dead" entry is a transaction that is no longer active.