Coder Social home page Coder Social logo

alexge233 / threadible Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 38 KB

A C++11 Header-Only Asynchronous Thread Pool for easy queuing tasks in an OOP manner

License: BSD 3-Clause "New" or "Revised" License

CMake 9.48% C++ 90.52%
c-plus-plus thread-pool boost service-io thread asio event-driven cxx11

threadible's Introduction

#Threadible

A C++11 Header only class, which allows you to use a one-time thread pool in an asynchronous (Event IO) way, by enapsulating your tasks or jobs in classes (OOP). For the benefits of thread-pools, please read the #Wikipedia article which summarizes what you gain.

This is a header-only library, so all you need is threadible.hpp and the associated boost headers:

Dependencies

  • libboost headers, thread and system

Building

There's nothing to build, just take a look at example.cpp If however you wanna see the example in action, then:

mkdir build
cd build
cmake ..
make
./thread_pool

Example

The example uses a minified and naive approach:

  • each task is allocated a resource
  • threadible has a set amount of available concurrent threads
  • threadible has a set amount of resources/assets

The idea is simple:

  • you add tasks (either data structures or functors)
  • each one of your asset objects handles a task
  • the queue in the thread pool will execute asynchronously and in parallel each task until no tasks remain
  • you can arbitrarily add more tasks when/if needed

The approach is simple; you can pre-allocate thread-specific memory, objects or handlers, and thus parallelise execution without worrying about sharing memory objects (you can of course still do that).

Execution uses boost's ASIO, and C++ std::thread so it should be very easy to port under different platforms, provided you have a fairly recent compiler.

See the example.cpp for a minified demonstration.

threadible's People

Contributors

alexge233 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

curioustauseef

threadible's Issues

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.