Giter Club home page Giter Club logo

threadpool's Introduction

Build Status Coverage Status

Introduction

Threadpool Class follows the threadpool pattern design :

  • Create multi thread slot
  • Task are loaded in thread slot.
  • If there is to much task compared to the number of thread slot, task are saved in a queue for waiting empty slot.

Your own Task must follow rules by inherinting from Task in <ThreadPool/Task.hpp> :

  • Add default constructor
  • Add void run() method (run is the core method in Tread)

ThreadPool class is not a singleton. You have to make sure you create only one instance in your program. Furthermore, ThreadPool is non-copyable.

Using of C++11 std::thread.

Examples

  #include <ThreadPool/ThreadPool.h>
  #include "PersonalTask.h"

  using namespace TP;

  ThreadPool<NB_THREAD, PersonalTask> threadPool;

  threadPool.submit( PersonalTask(0) );
  threadPool.submit( PersonalTask(1) );
  threadPool.submit( PersonalTask(2) );

Environment

Required tools and libraries :

  • CMake >= 2.8.0
  • gcc >= 4.9.2
  • clang >= 3.5.0

debian installation :

$ sudo apt-get install cmake gcc

Source recovery

git clone https://github.com/benoit-bst/threadPool

Compilation

# Create project_root/build
$ mkdir build
$ cd build
$ cmake -DENABLE_TESTING=ON ..
$ make

NOTES :

  • ENABLE_TESTING allows testing compilation
  • if you want to compile with clang, add -DCMAKE_CXX_COMPILER="/usr/bin/clang++" option

Running tests

# Inside project_root/tests
$ ./ThreadPoolTests

Library integration

Active modern c++ flag in your compiler like -std=c++11 and put in your cmake file :

add_subdirectory(ThreadPool)
include_directories( ${ThreadPool_headers_dir} )

threadpool's People

Contributors

benoit-bst avatar

Watchers

 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.