Skip to content

Commit 0d60177

Browse files
authored
Merge pull request #84 from antonio-rojas/boost-1.87
Fix build with boost 1.87
2 parents 5766200 + da140e4 commit 0d60177

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

libsrc/eclib/threadpool.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
#include <stdlib.h>
3434
#include <boost/thread/thread.hpp>
3535
#include <boost/thread/future.hpp>
36-
#include <boost/asio/io_service.hpp>
36+
#include <boost/asio/io_context.hpp>
37+
#include <boost/asio/post.hpp>
3738
#include <boost/shared_ptr.hpp>
3839

3940
class threadpool {
@@ -61,7 +62,7 @@ class threadpool {
6162
}
6263

6364
// Add reference to new task to job queue
64-
io_service_.post( boost::bind< void >( boost::ref( task ) ) );
65+
boost::asio::post(io_context_, boost::bind< void >( boost::ref( task ) ) );
6566
}
6667

6768
unsigned int getThreadCount();
@@ -72,8 +73,8 @@ class threadpool {
7273
unsigned int threadCount_;
7374
int verbose_;
7475

75-
boost::asio::io_service io_service_;
76-
boost::shared_ptr< boost::asio::io_service::work > work_;
76+
boost::asio::io_context io_context_;
77+
boost::asio::executor_work_guard<boost::asio::io_context::executor_type> work_;
7778
boost::thread_group threads_;
7879

7980
};

libsrc/threadpool.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*/
4848
threadpool::threadpool()
4949
: maxThreads_( 0 ), threadCount_( 0 ), verbose_( -1 ),
50-
work_( new boost::asio::io_service::work( io_service_ ) )
50+
work_( boost::asio::make_work_guard( io_context_ ) )
5151
{}
5252

5353
/**
@@ -56,7 +56,7 @@ threadpool::threadpool()
5656
* Main constructor.
5757
*/
5858
threadpool::threadpool( unsigned int numThreads, int verbose )
59-
: work_( new boost::asio::io_service::work( io_service_ ) ) {
59+
: work_( boost::asio::make_work_guard( io_context_ ) ) {
6060
start( numThreads, verbose );
6161
}
6262

@@ -104,7 +104,7 @@ void threadpool::start( unsigned int numThreads, int verbose ) {
104104

105105
// Create threads and add to threadpool
106106
for( unsigned int i = 0; i < threadCount_-1; i++ ) {
107-
threads_.create_thread( boost::bind( &boost::asio::io_service::run, &io_service_ ) );
107+
threads_.create_thread( boost::bind( &boost::asio::io_context::run, &io_context_ ) );
108108
}
109109
}
110110

@@ -127,10 +127,10 @@ void threadpool::close() {
127127
work_.reset();
128128

129129
// run() blocks until all posted jobs have finished
130-
io_service_.run();
130+
io_context_.run();
131131

132132
// We close the threadpool and join all threads
133-
io_service_.stop();
133+
io_context_.stop();
134134
threads_.join_all();
135135
}
136136

m4/ax_boost_asio.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ AC_DEFUN([AX_BOOST_ASIO],
6969
]],
7070
[[
7171
72-
boost::asio::io_service io;
72+
boost::asio::io_context io;
7373
boost::system::error_code timer_result;
7474
boost::asio::deadline_timer t(io);
7575
t.cancel();

0 commit comments

Comments
 (0)