Skip to content

Commit e3d2c61

Browse files
committed
Remove unused scheduler data members.
1 parent e4726b7 commit e3d2c61

10 files changed

Lines changed: 25 additions & 75 deletions

asio/include/asio/detail/impl/resolver_service_base.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private:
4444

4545
resolver_service_base::resolver_service_base(execution_context& context)
4646
: scheduler_(asio::use_service<scheduler_impl>(context)),
47-
work_scheduler_(new scheduler_impl(context, false)),
47+
work_scheduler_(new scheduler_impl(context)),
4848
work_thread_(),
4949
scheduler_locking_(config(context).get("scheduler", "locking", true))
5050
{

asio/include/asio/detail/impl/scheduler.ipp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,55 +109,33 @@ struct scheduler::work_cleanup
109109
};
110110

111111
scheduler::scheduler(asio::execution_context& ctx,
112-
bool own_thread, get_task_func_type get_task)
112+
get_task_func_type get_task)
113113
: asio::detail::execution_context_service_base<scheduler>(ctx),
114114
one_thread_(config(ctx).get("scheduler", "concurrency_hint", 0) == 1),
115115
mutex_(config(ctx).get("scheduler", "locking", true),
116116
config(ctx).get("scheduler", "locking_spin_count", 0)),
117117
task_(0),
118118
get_task_(get_task),
119119
task_interrupted_(true),
120-
outstanding_work_(0),
121120
stopped_(false),
122121
shutdown_(false),
123-
concurrency_hint_(config(ctx).get("scheduler", "concurrency_hint", 0)),
122+
outstanding_work_(0),
124123
task_usec_(config(ctx).get("scheduler", "task_usec", -1L)),
125-
wait_usec_(config(ctx).get("scheduler", "wait_usec", -1L)),
126-
thread_()
124+
wait_usec_(config(ctx).get("scheduler", "wait_usec", -1L))
127125
{
128126
ASIO_HANDLER_TRACKING_INIT;
129-
130-
if (own_thread)
131-
{
132-
++outstanding_work_;
133-
signal_blocker sb;
134-
thread_ = thread(thread_function(this));
135-
}
136127
}
137128

138129
scheduler::~scheduler()
139130
{
140-
if (thread_.joinable())
141-
{
142-
mutex::scoped_lock lock(mutex_);
143-
shutdown_ = true;
144-
stop_all_threads(lock);
145-
lock.unlock();
146-
thread_.join();
147-
}
148131
}
149132

150133
void scheduler::shutdown()
151134
{
152135
mutex::scoped_lock lock(mutex_);
153136
shutdown_ = true;
154-
if (thread_.joinable())
155-
stop_all_threads(lock);
156137
lock.unlock();
157138

158-
// Join thread to ensure task operation is returned to queue.
159-
thread_.join();
160-
161139
// Destroy handler objects.
162140
while (!op_queue_.empty())
163141
{

asio/include/asio/detail/impl/win_iocp_io_context.ipp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct win_iocp_io_context::timer_thread_function
7979
};
8080

8181
win_iocp_io_context::win_iocp_io_context(
82-
asio::execution_context& ctx, bool own_thread)
82+
asio::execution_context& ctx)
8383
: execution_context_service_base<win_iocp_io_context>(ctx),
8484
iocp_(),
8585
outstanding_work_(0),
@@ -102,21 +102,10 @@ win_iocp_io_context::win_iocp_io_context(
102102
asio::error::get_system_category());
103103
asio::detail::throw_error(ec, "iocp");
104104
}
105-
106-
if (own_thread)
107-
{
108-
::InterlockedIncrement(&outstanding_work_);
109-
thread_ = thread(thread_function(this));
110-
}
111105
}
112106

113107
win_iocp_io_context::~win_iocp_io_context()
114108
{
115-
if (thread_.joinable())
116-
{
117-
stop();
118-
thread_.join();
119-
}
120109
}
121110

122111
void win_iocp_io_context::shutdown()
@@ -130,13 +119,6 @@ void win_iocp_io_context::shutdown()
130119
::SetWaitableTimer(waitable_timer_.handle, &timeout, 1, 0, 0, FALSE);
131120
}
132121

133-
if (thread_.joinable())
134-
{
135-
stop();
136-
thread_.join();
137-
::InterlockedDecrement(&outstanding_work_);
138-
}
139-
140122
while (::InterlockedExchangeAdd(&outstanding_work_, 0) > 0)
141123
{
142124
op_queue<win_iocp_operation> ops;

asio/include/asio/detail/scheduler.hpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class scheduler
4848

4949
// Constructor.
5050
ASIO_DECL scheduler(asio::execution_context& ctx,
51-
bool own_thread = true,
5251
get_task_func_type get_task = &scheduler::get_default_task);
5352

5453
// Destructor.
@@ -203,29 +202,23 @@ class scheduler
203202
// Whether the task has been interrupted.
204203
bool task_interrupted_;
205204

206-
// The count of unfinished work.
207-
atomic_count outstanding_work_;
208-
209-
// The queue of handlers that are ready to be delivered.
210-
op_queue<operation> op_queue_;
211-
212205
// Flag to indicate that the dispatcher has been stopped.
213206
bool stopped_;
214207

215208
// Flag to indicate that the dispatcher has been shut down.
216209
bool shutdown_;
217210

218-
// The concurrency hint used to initialise the scheduler.
219-
const int concurrency_hint_;
211+
// The count of unfinished work.
212+
atomic_count outstanding_work_;
213+
214+
// The queue of handlers that are ready to be delivered.
215+
op_queue<operation> op_queue_;
220216

221217
// The time limit on running the scheduler task, in microseconds.
222218
const long task_usec_;
223219

224220
// The time limit on waiting when the queue is empty, in microseconds.
225221
const long wait_usec_;
226-
227-
// The thread that is running the scheduler.
228-
thread thread_;
229222
};
230223

231224
} // namespace detail

asio/include/asio/detail/win_iocp_io_context.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class win_iocp_io_context
4545
{
4646
public:
4747
// Constructor.
48-
ASIO_DECL win_iocp_io_context(
49-
asio::execution_context& ctx, bool own_thread = true);
48+
ASIO_DECL explicit win_iocp_io_context(
49+
asio::execution_context& ctx);
5050

5151
// Destructor.
5252
ASIO_DECL ~win_iocp_io_context();
@@ -320,9 +320,6 @@ class win_iocp_io_context
320320

321321
// The concurrency hint used to initialise the io_context.
322322
const int concurrency_hint_;
323-
324-
// The thread that is running the io_context.
325-
thread thread_;
326323
};
327324

328325
} // namespace detail

asio/include/asio/impl/io_context.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace asio {
3232
template <typename Allocator>
3333
io_context::io_context(allocator_arg_t, const Allocator& a)
3434
: execution_context(std::allocator_arg, a, config_from_concurrency_hint()),
35-
impl_(asio::make_service<impl_type>(*this, false))
35+
impl_(asio::make_service<impl_type>(*this))
3636
{
3737
}
3838

@@ -41,15 +41,15 @@ io_context::io_context(allocator_arg_t,
4141
const Allocator& a, int concurrency_hint)
4242
: execution_context(std::allocator_arg, a,
4343
config_from_concurrency_hint(concurrency_hint)),
44-
impl_(asio::make_service<impl_type>(*this, false))
44+
impl_(asio::make_service<impl_type>(*this))
4545
{
4646
}
4747

4848
template <typename Allocator>
4949
io_context::io_context(allocator_arg_t, const Allocator& a,
5050
const execution_context::service_maker& initial_services)
5151
: execution_context(std::allocator_arg, a, initial_services),
52-
impl_(asio::make_service<impl_type>(*this, false))
52+
impl_(asio::make_service<impl_type>(*this))
5353
{
5454
}
5555

asio/include/asio/impl/io_context.ipp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ namespace asio {
3535

3636
io_context::io_context()
3737
: execution_context(config_from_concurrency_hint()),
38-
impl_(asio::make_service<impl_type>(*this, false))
38+
impl_(asio::make_service<impl_type>(*this))
3939
{
4040
}
4141

4242
io_context::io_context(int concurrency_hint)
4343
: execution_context(config_from_concurrency_hint(concurrency_hint)),
44-
impl_(asio::make_service<impl_type>(*this, false))
44+
impl_(asio::make_service<impl_type>(*this))
4545
{
4646
}
4747

4848
io_context::io_context(const execution_context::service_maker& initial_services)
4949
: execution_context(initial_services),
50-
impl_(asio::make_service<impl_type>(*this, false))
50+
impl_(asio::make_service<impl_type>(*this))
5151
{
5252
}
5353

asio/include/asio/impl/system_context.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct system_context::thread_function
4545
};
4646

4747
system_context::system_context()
48-
: scheduler_(add_scheduler(new detail::scheduler(*this, false))),
48+
: scheduler_(add_scheduler(new detail::scheduler(*this))),
4949
threads_(std::allocator<void>())
5050
{
5151
scheduler_.work_started();

asio/include/asio/impl/thread_pool.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace asio {
3232
template <typename Allocator>
3333
thread_pool::thread_pool(allocator_arg_t, const Allocator& a)
3434
: execution_context(std::allocator_arg, a),
35-
scheduler_(asio::make_service<detail::scheduler>(*this, false)),
35+
scheduler_(asio::make_service<detail::scheduler>(*this)),
3636
threads_(allocator<void>(*this)),
3737
num_threads_(default_thread_pool_size()),
3838
joinable_(true)
@@ -47,7 +47,7 @@ thread_pool::thread_pool(allocator_arg_t,
4747
const Allocator& a, std::size_t num_threads)
4848
: execution_context(std::allocator_arg, a,
4949
config_from_concurrency_hint(num_threads == 1 ? 1 : 0)),
50-
scheduler_(asio::make_service<detail::scheduler>(*this, false)),
50+
scheduler_(asio::make_service<detail::scheduler>(*this)),
5151
threads_(allocator<void>(*this)),
5252
num_threads_(clamp_thread_pool_size(num_threads)),
5353
joinable_(true)
@@ -60,7 +60,7 @@ thread_pool::thread_pool(allocator_arg_t,
6060
const Allocator& a, std::size_t num_threads,
6161
const execution_context::service_maker& initial_services)
6262
: execution_context(std::allocator_arg, a, initial_services),
63-
scheduler_(asio::make_service<detail::scheduler>(*this, false)),
63+
scheduler_(asio::make_service<detail::scheduler>(*this)),
6464
threads_(allocator<void>(*this)),
6565
num_threads_(clamp_thread_pool_size(num_threads)),
6666
joinable_(true)

asio/include/asio/impl/thread_pool.ipp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ long thread_pool::default_thread_pool_size()
5656
}
5757

5858
thread_pool::thread_pool()
59-
: scheduler_(asio::make_service<detail::scheduler>(*this, false)),
59+
: scheduler_(asio::make_service<detail::scheduler>(*this)),
6060
threads_(allocator<void>(*this)),
6161
num_threads_(default_thread_pool_size()),
6262
joinable_(true)
@@ -78,7 +78,7 @@ long thread_pool::clamp_thread_pool_size(std::size_t n)
7878

7979
thread_pool::thread_pool(std::size_t num_threads)
8080
: execution_context(config_from_concurrency_hint(num_threads == 1 ? 1 : 0)),
81-
scheduler_(asio::make_service<detail::scheduler>(*this, false)),
81+
scheduler_(asio::make_service<detail::scheduler>(*this)),
8282
threads_(allocator<void>(*this)),
8383
num_threads_(clamp_thread_pool_size(num_threads)),
8484
joinable_(true)
@@ -89,7 +89,7 @@ thread_pool::thread_pool(std::size_t num_threads)
8989
thread_pool::thread_pool(std::size_t num_threads,
9090
const execution_context::service_maker& initial_services)
9191
: execution_context(initial_services),
92-
scheduler_(asio::make_service<detail::scheduler>(*this, false)),
92+
scheduler_(asio::make_service<detail::scheduler>(*this)),
9393
threads_(allocator<void>(*this)),
9494
num_threads_(clamp_thread_pool_size(num_threads)),
9595
joinable_(true)

0 commit comments

Comments
 (0)