| 354 | |
| 355 | |
| 356 | template<class T> NetSocket ReservedSocketList<T>::reserve(SOCKET reserveId, bool doLock) |
| 357 | { |
| 358 | MutexHandle handle; |
| 359 | if (doLock) |
| 360 | { |
| 361 | handle.lock(mMutex, true); |
| 362 | } |
| 363 | |
| 364 | S32 idx = mSocketList.find_next(EntryType()); |
| 365 | if (idx == -1) |
| 366 | { |
| 367 | EntryType entry; |
| 368 | entry.value = reserveId; |
| 369 | entry.used = true; |
| 370 | mSocketList.push_back(entry); |
| 371 | return NetSocket::fromHandle(mSocketList.size() - 1); |
| 372 | } |
| 373 | else |
| 374 | { |
| 375 | EntryType &entry = mSocketList[idx]; |
| 376 | entry.used = true; |
| 377 | entry.value = reserveId; |
| 378 | } |
| 379 | |
| 380 | return NetSocket::fromHandle(idx); |
| 381 | } |
| 382 | |
| 383 | template<class T> void ReservedSocketList<T>::remove(NetSocket socketToRemove, bool doLock) |
| 384 | { |