Coder Social home page Coder Social logo

dmthuc / object-pool Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 26 KB

C++ Fast, Static and Generic Object Pool library with smart pointer

License: GNU General Public License v3.0

CMake 14.96% C++ 85.04%
objectpool cpp14 smart-pointer static-object-pool-cpp

object-pool's Introduction

Object-Pool with smart-pointer Build Status

C++ Fast, Static and Generic Object Pool library with smart pointer
This is static object pool library. It mean that object pool has fixed number of object it manages. Client can't add more object after initialization.
Because it is static so there's no malloc and all operators except constructors are noexcept and fast.

#include "pool.hpp"

Pool<int, 6> pool;
auto obj1 = pool.acquire();
if (nullptr != obj.get())
    dosomething(*obj);
else
    throw("no object in pool available");

//with compound type, client can pass parameters for the constructor of containing object
Pool<Foo, 6> pool{args1, args2}

//can also construct it with a range, this is the most useful case.
vector<Foo> vec{Foo{1}, Foo{2});
//each element of the range will be moved to pool, client have to keep track of number himself
Pool<Foo, 2> pool(vec.begin(), vec.end());

//also can construct with initializer list, which will be copied from.
Pool<Foo, 2> pool{Foo{1}, Foo{2}};

//iterate to const element
for(const auto& e: pool)
    cout<<e;

object-pool's People

Contributors

dmthuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.