Giter Site home page Giter Site logo

cppthreadpool's Introduction

CPPThreadPool

Author: Arun Nadesh R([email protected])

A simple thread pool library implemented using C++, pthread library and C++ wrappers to pthread library. This will create a .so lib libthreadpool.so and the same can be linked with any application which requires a producer-consumer model of processing jobs. This is a cmake based project and it is advisable to create a separate build directory and build.

Dependencies:

  libpthread

Public Headers:

   Job.h,
   Threadpool.h

Steps to build and install:

mkdir <builddir>
cd <builddir>
cmake <path-to-source-ThreadPool> -DCMAKE_BUILD_TYPE=<Release or Debug>
make
make install

The library will be installed in /usr/local/lib/threadpool
The headers will be installed in /sr/local/include/threadpool

Steps to make RPM:

mkdir <builddir>
cd <builddir>
cmake <path-to-source-ThreadPool> -DCMAKE_BUILD_TYPE=<Release or Debug>
make  
make package

This will build the RPM libthreadpool-1.0.0-1.x86_64.rpm
To install rpm package in /usr/local/lib/threadpool  and /sr/local/include/threadpool
 rpm -ivh libthreadpool-1.0.0-1.x86_64.rpm
 
To revert the RPM
 rpm -e libthreadpool

Sample Application: A sample app built using libthreadpool.so is demonstrated in Threadpooldriver.cpp

......
   Threadpool thPool(3);

if(TH_POOL_CREATE_SUCCESS == thPool.threadpool_create()) {

    for(int i=0; i<10; i++){

          Job* jb =  new Job(&testFun, &jobID[i]);
          if(jb){
             cout<<"Adding new job index: "<<jobID[i]<<endl;
             thPool.threadpool_add_job(jb);
          }
    }
}
sleep(30);
thPool.threadpool_destroy();
........

cppthreadpool's People

Contributors

arunnadesh avatar

Watchers

James Cloos 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.