Skip to content

Commit ee609e8

Browse files
committed
Cleanup header includes.
1. Make inclusion of boost/bind/bind.hpp conditional in some cases, when the code actually conditionally uses boost::bind. Reduces compile-time overhead and fixes #307. 2. Remove some unnecessary uses of boost::ref. This allows to avoid including boost/core/ref.hpp in a few places, and avoids the associated template instantiation overhead in others. 3. Replace deprecated header includes with the more recent alternatives. For example: boost/detail/lightweight_test.hpp -> boost/core/lightweight_test.hpp, boost/ref.hpp -> boost/core/ref.hpp. 4. Replace some blanket includes with the more fine-grained ones. For example, boost/utility.hpp, boost/atomic.hpp. This reduces compile time overhead. 5. Add some missing includes, for example, boost/core/ref.hpp and boost/type_traits/is_same.hpp. 6. Replace uses of std::is_same with boost::is_same (with the corresponding included header) since the standard type_traits header presence and validity is not tested by the code. Using boost::is_same makes the code more portable.
1 parent c13beec commit ee609e8

File tree

362 files changed

+472
-445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

362 files changed

+472
-445
lines changed

Diff for: include/boost/thread/concurrent_queues/detail/sync_deque_base.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//////////////////////////////////////////////////////////////////////////////
1313

1414
#include <boost/bind/bind.hpp>
15+
#include <boost/core/ref.hpp>
1516

1617
#include <boost/thread/detail/config.hpp>
1718
#include <boost/thread/condition_variable.hpp>
@@ -187,7 +188,7 @@ namespace detail
187188
template <class ValueType, class Queue>
188189
bool sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
189190
{
190-
cond_.wait(lk, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk)));
191+
cond_.wait(lk, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk)));
191192
if (! empty(lk)) return false; // success
192193
return true; // closed
193194
}
@@ -196,7 +197,7 @@ namespace detail
196197
template <class WClock, class Duration>
197198
queue_op_status sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed_until(unique_lock<mutex>& lk, chrono::time_point<WClock,Duration> const&tp)
198199
{
199-
if (! cond_.wait_until(lk, tp, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk))))
200+
if (! cond_.wait_until(lk, tp, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk))))
200201
return queue_op_status::timeout;
201202
if (! empty(lk)) return queue_op_status::success;
202203
return queue_op_status::closed;

Diff for: include/boost/thread/concurrent_queues/detail/sync_queue_base.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//////////////////////////////////////////////////////////////////////////////
1313

1414
#include <boost/bind/bind.hpp>
15+
#include <boost/core/ref.hpp>
1516

1617
#include <boost/thread/detail/config.hpp>
1718
#include <boost/thread/condition_variable.hpp>
@@ -187,7 +188,7 @@ namespace detail
187188
template <class ValueType, class Queue>
188189
bool sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
189190
{
190-
cond_.wait(lk, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk)));
191+
cond_.wait(lk, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk)));
191192
if (! empty(lk)) return false; // success
192193
return true; // closed
193194
}
@@ -196,7 +197,7 @@ namespace detail
196197
template <class WClock, class Duration>
197198
queue_op_status sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed_until(unique_lock<mutex>& lk, chrono::time_point<WClock,Duration> const&tp)
198199
{
199-
if (! cond_.wait_until(lk, tp, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk))))
200+
if (! cond_.wait_until(lk, tp, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk))))
200201
return queue_op_status::timeout;
201202
if (! empty(lk)) return queue_op_status::success;
202203
return queue_op_status::closed;

Diff for: include/boost/thread/detail/thread.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <algorithm>
3131
#include <boost/core/ref.hpp>
3232
#include <boost/cstdint.hpp>
33-
#include <boost/bind/bind.hpp>
3433
#include <stdlib.h>
3534
#include <memory>
3635
#include <boost/core/enable_if.hpp>
@@ -47,6 +46,8 @@
4746

4847
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
4948
#include <tuple>
49+
#else
50+
#include <boost/bind/bind.hpp>
5051
#endif
5152
#include <boost/config/abi_prefix.hpp>
5253

Diff for: include/boost/thread/future.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ namespace boost
393393
is_deferred_=false;
394394
execute(lk);
395395
}
396-
waiters.wait(lk, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
396+
waiters.wait(lk, boost::bind(&shared_state_base::is_done, this));
397397
if(rethrow && exception)
398398
{
399399
boost::rethrow_exception(exception);
@@ -420,7 +420,7 @@ namespace boost
420420
return false;
421421

422422
do_callback(lock);
423-
return waiters.timed_wait(lock, rel_time, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
423+
return waiters.timed_wait(lock, rel_time, boost::bind(&shared_state_base::is_done, this));
424424
}
425425

426426
bool timed_wait_until(boost::system_time const& target_time)
@@ -430,7 +430,7 @@ namespace boost
430430
return false;
431431

432432
do_callback(lock);
433-
return waiters.timed_wait(lock, target_time, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
433+
return waiters.timed_wait(lock, target_time, boost::bind(&shared_state_base::is_done, this));
434434
}
435435
#endif
436436
#ifdef BOOST_THREAD_USES_CHRONO
@@ -443,7 +443,7 @@ namespace boost
443443
if (is_deferred_)
444444
return future_status::deferred;
445445
do_callback(lock);
446-
if(!waiters.wait_until(lock, abs_time, boost::bind(&shared_state_base::is_done, boost::ref(*this))))
446+
if(!waiters.wait_until(lock, abs_time, boost::bind(&shared_state_base::is_done, this)))
447447
{
448448
return future_status::timeout;
449449
}
@@ -940,7 +940,7 @@ namespace boost
940940
join();
941941
#elif defined BOOST_THREAD_ASYNC_FUTURE_WAITS
942942
unique_lock<boost::mutex> lk(this->mutex);
943-
this->waiters.wait(lk, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
943+
this->waiters.wait(lk, boost::bind(&shared_state_base::is_done, this));
944944
#endif
945945
}
946946

Diff for: include/boost/thread/pthread/once.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
#include <boost/thread/detail/delete.hpp>
2020
#include <boost/core/no_exceptions_support.hpp>
2121

22-
#include <boost/bind/bind.hpp>
2322
#include <boost/assert.hpp>
24-
#include <boost/config/abi_prefix.hpp>
25-
2623
#include <boost/cstdint.hpp>
2724
#include <pthread.h>
2825
#include <csignal>
2926

27+
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
28+
#include <boost/bind/bind.hpp>
29+
#endif
30+
31+
#include <boost/config/abi_prefix.hpp>
32+
3033
namespace boost
3134
{
3235

Diff for: include/boost/thread/pthread/once_atomic.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
#include <boost/thread/detail/move.hpp>
1717
#include <boost/thread/detail/invoke.hpp>
1818
#include <boost/core/no_exceptions_support.hpp>
19+
#include <boost/atomic/capabilities.hpp>
20+
#include <boost/atomic/atomic.hpp>
21+
22+
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
1923
#include <boost/bind/bind.hpp>
20-
#include <boost/atomic.hpp>
24+
#endif
2125

2226
#include <boost/config/abi_prefix.hpp>
2327

Diff for: include/boost/thread/pthread/shared_mutex.hpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ namespace boost
171171
boost::this_thread::disable_interruption do_not_disturb;
172172
#endif
173173
boost::unique_lock<boost::mutex> lk(state_change);
174-
shared_cond.wait(lk, boost::bind(&state_data::can_lock_shared, boost::ref(state)));
174+
shared_cond.wait(lk, boost::bind(&state_data::can_lock_shared, &state));
175175
state.lock_shared();
176176
}
177177

@@ -194,7 +194,7 @@ namespace boost
194194
boost::this_thread::disable_interruption do_not_disturb;
195195
#endif
196196
boost::unique_lock<boost::mutex> lk(state_change);
197-
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
197+
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_shared, &state)))
198198
{
199199
return false;
200200
}
@@ -209,7 +209,7 @@ namespace boost
209209
boost::this_thread::disable_interruption do_not_disturb;
210210
#endif
211211
boost::unique_lock<boost::mutex> lk(state_change);
212-
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
212+
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_shared, &state)))
213213
{
214214
return false;
215215
}
@@ -230,7 +230,7 @@ namespace boost
230230
boost::this_thread::disable_interruption do_not_disturb;
231231
#endif
232232
boost::unique_lock<boost::mutex> lk(state_change);
233-
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
233+
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_shared, &state)))
234234
{
235235
return false;
236236
}
@@ -270,7 +270,7 @@ namespace boost
270270
#endif
271271
boost::unique_lock<boost::mutex> lk(state_change);
272272
state.exclusive_waiting_blocked=true;
273-
exclusive_cond.wait(lk, boost::bind(&state_data::can_lock, boost::ref(state)));
273+
exclusive_cond.wait(lk, boost::bind(&state_data::can_lock, &state));
274274
state.exclusive=true;
275275
}
276276

@@ -282,7 +282,7 @@ namespace boost
282282
#endif
283283
boost::unique_lock<boost::mutex> lk(state_change);
284284
state.exclusive_waiting_blocked=true;
285-
if(!exclusive_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock, boost::ref(state))))
285+
if(!exclusive_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock, &state)))
286286
{
287287
state.exclusive_waiting_blocked=false;
288288
release_waiters();
@@ -300,7 +300,7 @@ namespace boost
300300
#endif
301301
boost::unique_lock<boost::mutex> lk(state_change);
302302
state.exclusive_waiting_blocked=true;
303-
if(!exclusive_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock, boost::ref(state))))
303+
if(!exclusive_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock, &state)))
304304
{
305305
state.exclusive_waiting_blocked=false;
306306
release_waiters();
@@ -324,7 +324,7 @@ namespace boost
324324
#endif
325325
boost::unique_lock<boost::mutex> lk(state_change);
326326
state.exclusive_waiting_blocked=true;
327-
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock, boost::ref(state))))
327+
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock, &state)))
328328
{
329329
state.exclusive_waiting_blocked=false;
330330
release_waiters();
@@ -362,7 +362,7 @@ namespace boost
362362
boost::this_thread::disable_interruption do_not_disturb;
363363
#endif
364364
boost::unique_lock<boost::mutex> lk(state_change);
365-
shared_cond.wait(lk, boost::bind(&state_data::can_lock_upgrade, boost::ref(state)));
365+
shared_cond.wait(lk, boost::bind(&state_data::can_lock_upgrade, &state));
366366
state.lock_shared();
367367
state.upgrade=true;
368368
}
@@ -374,7 +374,7 @@ namespace boost
374374
boost::this_thread::disable_interruption do_not_disturb;
375375
#endif
376376
boost::unique_lock<boost::mutex> lk(state_change);
377-
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
377+
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_upgrade, &state)))
378378
{
379379
return false;
380380
}
@@ -390,7 +390,7 @@ namespace boost
390390
boost::this_thread::disable_interruption do_not_disturb;
391391
#endif
392392
boost::unique_lock<boost::mutex> lk(state_change);
393-
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
393+
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_upgrade, &state)))
394394
{
395395
return false;
396396
}
@@ -412,7 +412,7 @@ namespace boost
412412
boost::this_thread::disable_interruption do_not_disturb;
413413
#endif
414414
boost::unique_lock<boost::mutex> lk(state_change);
415-
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
415+
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, &state)))
416416
{
417417
return false;
418418
}
@@ -457,7 +457,7 @@ namespace boost
457457
boost::unique_lock<boost::mutex> lk(state_change);
458458
state.assert_lock_upgraded();
459459
state.unlock_shared();
460-
upgrade_cond.wait(lk, boost::bind(&state_data::no_shared, boost::ref(state)));
460+
upgrade_cond.wait(lk, boost::bind(&state_data::no_shared, &state));
461461
state.upgrade=false;
462462
state.exclusive=true;
463463
state.assert_locked();
@@ -511,7 +511,7 @@ namespace boost
511511
#endif
512512
boost::unique_lock<boost::mutex> lk(state_change);
513513
state.assert_lock_upgraded();
514-
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, boost::ref(state))))
514+
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, &state)))
515515
{
516516
return false;
517517
}
@@ -569,7 +569,7 @@ namespace boost
569569
#endif
570570
boost::unique_lock<boost::mutex> lk(state_change);
571571
state.assert_lock_shared();
572-
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, boost::ref(state))))
572+
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, &state)))
573573
{
574574
return false;
575575
}
@@ -623,7 +623,7 @@ namespace boost
623623
#endif
624624
boost::unique_lock<boost::mutex> lk(state_change);
625625
state.assert_lock_shared();
626-
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
626+
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, &state)))
627627
{
628628
return false;
629629
}

0 commit comments

Comments
 (0)