/usr/include/eclib/threadpool.h is in libec-dev 20171002-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | // FILE threadpool.h : Declaration of class threadpool
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2012 Marcus Mo
//
// This file is part of the eclib package.
//
// eclib is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// eclib is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eclib; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
//
//////////////////////////////////////////////////////////////////////////
// Include only if Boost installed
#ifdef ECLIB_MULTITHREAD
#ifndef THREADPOOL_H
#define THREADPOOL_H
// Include headers based on
// available packages on system
#include <iostream>
#include <stdlib.h>
#include <boost/thread/thread.hpp>
#include <boost/thread/future.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/shared_ptr.hpp>
class threadpool {
public:
threadpool();
threadpool( unsigned int numThreads, int verbose );
~threadpool();
void start( unsigned int numThreads, int verbose );
void close();
/**
* post()
*
* Add a job to the job queue so that the next
* idle thread in the threadpool may execute it.
* Templated function must reside in header file.
*/
template< class Task >
void post( Task &task ) {
// Check start() was called
if( verbose_ == -1 ) {
std::cout << "Must call start() before using post(). Exiting ..." << std::endl;
exit(1);
}
// Add reference to new task to job queue
io_service_.post( boost::bind< void >( boost::ref( task ) ) );
}
unsigned int getThreadCount();
unsigned int getMaxThreads();
private:
unsigned int maxThreads_;
unsigned int threadCount_;
int verbose_;
boost::asio::io_service io_service_;
boost::shared_ptr< boost::asio::io_service::work > work_;
boost::thread_group threads_;
};
#endif // THREADPOOL_H
#endif // ECLIB_MULTITHREAD
|