MCPcopy Create free account
hub / github.com/Snapchat/Valdi / Pool

Class Pool

valdi/test/runtime/ObjectPool_tests.cpp:28–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26using ReusableObject = ObjectPoolEntry<Shared<Object>, void (*)(Shared<Object>&)>;
27
28class Pool {
29public:
30 ReusableObject create() {
31 return _innerPool.getOrCreate(
32 [&]() {
33 _createdObjectsCount++;
34 return Valdi::makeShared<Object>();
35 },
36 &cleanUpObject);
37 }
38
39 int getCreatedObjectsCount() const {
40 return _createdObjectsCount;
41 }
42
43private:
44 ObjectPoolInner<Shared<Object>> _innerPool;
45 int _createdObjectsCount = 0;
46};
47
48TEST(ObjectPool, canCreateAndReuse) {
49 auto pool = Pool();

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68