@@ -94,12 +94,12 @@ int main() {
9494 slick::ObjectPool<MyObject > pool(1024);
9595
9696 // Allocate object from pool
97- MyObject* obj = pool.allocate_object ();
97+ MyObject* obj = pool.allocate ();
9898 obj->id = 42;
9999 obj->value = 3.14;
100100
101101 // Return object to pool
102- pool.free_object (obj);
102+ pool.free (obj);
103103
104104 return 0;
105105}
@@ -170,15 +170,15 @@ int main() {
170170 slick::ObjectPool<Message > pool(512);
171171
172172 // Allocate from pool
173- Message* msg = pool.allocate_object ();
173+ Message* msg = pool.allocate ();
174174 msg->id = 1;
175175 std::strcpy(msg->data, "Hello, World!");
176176
177177 // Use the object...
178178 std::cout << "Message: " << msg->data << std::endl;
179179
180180 // Return to pool when done
181- pool.free_object (msg);
181+ pool.free (msg);
182182
183183 return 0;
184184}
@@ -199,14 +199,14 @@ struct WorkItem {
199199void worker_thread(slick::ObjectPool<WorkItem>& pool, int thread_id) {
200200 for (int i = 0; i < 10000; ++i) {
201201 // Allocate from pool (lock-free)
202- WorkItem* item = pool.allocate_object ();
202+ WorkItem* item = pool.allocate ();
203203
204204 // Do work
205205 item->task_id = thread_id * 10000 + i;
206206 process_work(*item);
207207
208208 // Return to pool (lock-free)
209- pool.free_object (item);
209+ pool.free (item);
210210 }
211211}
212212
@@ -235,8 +235,8 @@ int main() {
235235
236236The pool uses atomic compare-and-swap (CAS) operations to coordinate multiple producers and consumers without locks:
237237
238- - ** Producers** (threads calling ` allocate_object ()` ) atomically reserve slots from the pool
239- - ** Consumers** (threads calling ` free_object ()` ) atomically return objects to the pool
238+ - ** Producers** (threads calling ` allocate ()` ) atomically reserve slots from the pool
239+ - ** Consumers** (threads calling ` free ()` ) atomically return objects to the pool
240240- ** Ring buffer** wrapping is handled atomically without blocking
241241- ** No spinlocks, no mutexes** - truly wait-free for successful operations
242242
@@ -315,13 +315,13 @@ ObjectPool(uint32_t size);
315315
316316```cpp
317317// Allocate an object from the pool
318- T* allocate_object ();
318+ T* allocate ();
319319```
320320Returns a pointer to an object from the pool. If pool is exhausted, allocates a new object from heap.
321321
322322``` cpp
323323// Return an object to the pool
324- void free_object (T* obj);
324+ void free (T* obj);
325325```
326326Returns an object to the pool if it belongs to the pool, otherwise deletes it.
327327
@@ -454,8 +454,8 @@ sudo cmake --install .
454454
455455### Guarantees
456456
457- - ✅ ** Multiple producers** can call ` allocate_object ()` concurrently
458- - ✅ ** Multiple consumers** can call ` free_object ()` concurrently
457+ - ✅ ** Multiple producers** can call ` allocate ()` concurrently
458+ - ✅ ** Multiple consumers** can call ` free ()` concurrently
459459- ✅ ** Mixed operations** (allocate + free) are safe
460460- ❌ ** reset()** is NOT thread-safe (use when no other threads are active)
461461
@@ -488,11 +488,11 @@ slick::ObjectPool<T> pool(1000);
488488### Pool Exhaustion Handling
489489
490490```cpp
491- // When pool is exhausted, allocate_object () allocates from heap
492- T* obj = pool.allocate_object (); // May return heap-allocated object
491+ // When pool is exhausted, allocate () allocates from heap
492+ T* obj = pool.allocate (); // May return heap-allocated object
493493
494494// free_object() detects and handles both cases
495- pool.free_object (obj); // Works for pool or heap objects
495+ pool.free (obj); // Works for pool or heap objects
496496```
497497
498498### Type Design
@@ -536,7 +536,7 @@ struct FixedType {
536536## FAQ
537537
538538**Q: What happens when the pool is exhausted?**
539- A: `allocate_object ()` automatically allocates from heap. `free_object ()` detects and deletes heap-allocated objects.
539+ A: `allocate ()` automatically allocates from heap. `free ()` detects and deletes heap-allocated objects.
540540
541541**Q: Can I use std::string or std::vector in pooled objects?**
542542A: Yes! The pool works with any default constructible type, including std::string, std::vector, and other standard containers.
0 commit comments