* Return an object. * @return An object, or throws an exception on failure. */
| 58 | * @return An object, or throws an exception on failure. |
| 59 | */ |
| 60 | ObjectType newObject() |
| 61 | { |
| 62 | // Retire the active object |
| 63 | Data data; |
| 64 | data.alloc = mActiveObject; |
| 65 | data.timestamp = mpFence->getSignaledValue(); |
| 66 | mQueue.push(data); |
| 67 | |
| 68 | // The queue is sorted based on time. Check if the first object is free |
| 69 | data = mQueue.front(); |
| 70 | if (data.timestamp < mpFence->getCurrentValue()) |
| 71 | { |
| 72 | mQueue.pop(); |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | data.alloc = createObject(); |
| 77 | } |
| 78 | |
| 79 | mActiveObject = data.alloc; |
| 80 | return mActiveObject; |
| 81 | } |
| 82 | |
| 83 | private: |
| 84 | FencedPool(ref<Fence> pFence, NewObjectFuncType newFunc, void* pUserData) : mNewObjFunc(newFunc), mpFence(pFence), mpUserData(pUserData) |
nothing calls this directly
no test coverage detected