| 401 | |
| 402 | |
| 403 | template<class T> NetSocket ReservedSocketList<T>::reserve(SOCKET reserveId, bool doLock) |
| 404 | { |
| 405 | MutexHandle handle; |
| 406 | if (doLock) |
| 407 | { |
| 408 | handle.lock(mMutex, true); |
| 409 | } |
| 410 | |
| 411 | S32 idx = mSocketList.find_next(EntryType()); |
| 412 | if (idx == -1) |
| 413 | { |
| 414 | EntryType entry; |
| 415 | entry.value = reserveId; |
| 416 | entry.used = true; |
| 417 | mSocketList.push_back(entry); |
| 418 | return NetSocket::fromHandle(mSocketList.size() - 1); |
| 419 | } |
| 420 | else |
| 421 | { |
| 422 | EntryType &entry = mSocketList[idx]; |
| 423 | entry.used = true; |
| 424 | entry.value = reserveId; |
| 425 | } |
| 426 | |
| 427 | return NetSocket::fromHandle(idx); |
| 428 | } |
| 429 | |
| 430 | template<class T> void ReservedSocketList<T>::remove(NetSocket socketToRemove, bool doLock) |
| 431 | { |