| 32 | |
| 33 | struct AudioSamplePool { |
| 34 | void put(SampleImplPtr&& impl) { |
| 35 | if (impl.unique()) { |
| 36 | // There is no more shared_ptr to this object, so we can recycle it. |
| 37 | fl::unique_lock<fl::mutex> lock(mutex); |
| 38 | if (impl && pool.size() < MAX_POOL_SIZE) { |
| 39 | // Reset the impl for reuse (clear internal state) |
| 40 | impl->reset(); |
| 41 | pool.push_back(impl); |
| 42 | return; |
| 43 | } |
| 44 | } |
| 45 | // Pool is full, discard the impl |
| 46 | impl.reset(); |
| 47 | } |
| 48 | SampleImplPtr getOrCreate() { |
| 49 | { |
| 50 | fl::unique_lock<fl::mutex> lock(mutex); |
no test coverage detected