Skip to content

Commit df973a8

Browse files
committed
Remove support for boost.coroutine-based spawn().
The spawn() function now works only with the fiber support in boost.context.
1 parent d6e7b5a commit df973a8

File tree

5 files changed

+0
-493
lines changed

5 files changed

+0
-493
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ target_link_libraries(boost_asio
1818
Boost::assert
1919
Boost::config
2020
Boost::context
21-
Boost::coroutine
2221
Boost::date_time
2322
Boost::system
2423
Boost::throw_exception

example/cpp11/spawn/Jamfile.v2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ lib network ; # HAIKU
1515
exe server
1616
: echo_server.cpp
1717
/boost/context//boost_context
18-
/boost/coroutine//boost_coroutine
1918
/boost/system//boost_system
2019
: <define>BOOST_ALL_NO_LIB=1
2120
<threading>multi

include/boost/asio/detail/config.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,6 @@
439439
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_DATE_TIME)
440440
#endif // !defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
441441

442-
// Boost support for the Coroutine library.
443-
#if !defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
444-
# if !defined(BOOST_ASIO_DISABLE_BOOST_COROUTINE)
445-
# define BOOST_ASIO_HAS_BOOST_COROUTINE 1
446-
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_COROUTINE)
447-
#endif // !defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
448-
449442
// Boost support for the Context library's fibers.
450443
#if !defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER)
451444
# if !defined(BOOST_ASIO_DISABLE_BOOST_CONTEXT_FIBER)

include/boost/asio/impl/spawn.hpp

Lines changed: 0 additions & 303 deletions
Original file line numberDiff line numberDiff line change
@@ -50,137 +50,6 @@ inline void spawned_thread_rethrow(void* ex)
5050
}
5151
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
5252

53-
#if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
54-
55-
// Spawned thread implementation using Boost.Coroutine.
56-
class spawned_coroutine_thread : public spawned_thread_base
57-
{
58-
public:
59-
#if defined(BOOST_COROUTINES_UNIDIRECT) || defined(BOOST_COROUTINES_V2)
60-
typedef boost::coroutines::pull_coroutine<void> callee_type;
61-
typedef boost::coroutines::push_coroutine<void> caller_type;
62-
#else
63-
typedef boost::coroutines::coroutine<void()> callee_type;
64-
typedef boost::coroutines::coroutine<void()> caller_type;
65-
#endif
66-
67-
spawned_coroutine_thread(caller_type& caller)
68-
: caller_(caller),
69-
on_suspend_fn_(0),
70-
on_suspend_arg_(0)
71-
{
72-
}
73-
74-
template <typename F>
75-
static spawned_thread_base* spawn(F&& f,
76-
const boost::coroutines::attributes& attributes,
77-
cancellation_slot parent_cancel_slot = cancellation_slot(),
78-
cancellation_state cancel_state = cancellation_state())
79-
{
80-
spawned_coroutine_thread* spawned_thread = 0;
81-
callee_type callee(entry_point<decay_t<F>>(
82-
static_cast<F&&>(f), &spawned_thread), attributes);
83-
spawned_thread->callee_.swap(callee);
84-
spawned_thread->parent_cancellation_slot_ = parent_cancel_slot;
85-
spawned_thread->cancellation_state_ = cancel_state;
86-
return spawned_thread;
87-
}
88-
89-
template <typename F>
90-
static spawned_thread_base* spawn(F&& f,
91-
cancellation_slot parent_cancel_slot = cancellation_slot(),
92-
cancellation_state cancel_state = cancellation_state())
93-
{
94-
return spawn(static_cast<F&&>(f), boost::coroutines::attributes(),
95-
parent_cancel_slot, cancel_state);
96-
}
97-
98-
void resume()
99-
{
100-
callee_();
101-
if (on_suspend_fn_)
102-
{
103-
void (*fn)(void*) = on_suspend_fn_;
104-
void* arg = on_suspend_arg_;
105-
on_suspend_fn_ = 0;
106-
fn(arg);
107-
}
108-
}
109-
110-
void suspend_with(void (*fn)(void*), void* arg)
111-
{
112-
if (throw_if_cancelled_)
113-
if (!!cancellation_state_.cancelled())
114-
throw_error(boost::asio::error::operation_aborted, "yield");
115-
has_context_switched_ = true;
116-
on_suspend_fn_ = fn;
117-
on_suspend_arg_ = arg;
118-
caller_();
119-
}
120-
121-
void destroy()
122-
{
123-
callee_type callee;
124-
callee.swap(callee_);
125-
if (terminal_)
126-
callee();
127-
}
128-
129-
private:
130-
template <typename Function>
131-
class entry_point
132-
{
133-
public:
134-
template <typename F>
135-
entry_point(F&& f,
136-
spawned_coroutine_thread** spawned_thread_out)
137-
: function_(static_cast<F&&>(f)),
138-
spawned_thread_out_(spawned_thread_out)
139-
{
140-
}
141-
142-
void operator()(caller_type& caller)
143-
{
144-
Function function(static_cast<Function&&>(function_));
145-
spawned_coroutine_thread spawned_thread(caller);
146-
*spawned_thread_out_ = &spawned_thread;
147-
spawned_thread_out_ = 0;
148-
spawned_thread.suspend();
149-
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
150-
try
151-
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
152-
{
153-
function(&spawned_thread);
154-
spawned_thread.terminal_ = true;
155-
spawned_thread.suspend();
156-
}
157-
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
158-
catch (const boost::coroutines::detail::forced_unwind&)
159-
{
160-
throw;
161-
}
162-
catch (...)
163-
{
164-
exception_ptr ex = current_exception();
165-
spawned_thread.terminal_ = true;
166-
spawned_thread.suspend_with(spawned_thread_rethrow, &ex);
167-
}
168-
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
169-
}
170-
171-
private:
172-
Function function_;
173-
spawned_coroutine_thread** spawned_thread_out_;
174-
};
175-
176-
caller_type& caller_;
177-
callee_type callee_;
178-
void (*on_suspend_fn_)(void*);
179-
void* on_suspend_arg_;
180-
};
181-
182-
#endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
183-
18453
#if defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER)
18554

18655
// Spawned thread implementation using Boost.Context's fiber.
@@ -313,8 +182,6 @@ class spawned_fiber_thread : public spawned_thread_base
313182

314183
#if defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER)
315184
typedef spawned_fiber_thread default_spawned_thread_type;
316-
#elif defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
317-
typedef spawned_coroutine_thread default_spawned_thread_type;
318185
#else
319186
# error No spawn() implementation available
320187
#endif
@@ -880,12 +747,6 @@ class spawn_entry_point
880747
throw;
881748
}
882749
# endif // defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER)
883-
# if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
884-
catch (const boost::coroutines::detail::forced_unwind&)
885-
{
886-
throw;
887-
}
888-
# endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
889750
catch (...)
890751
{
891752
exception_ptr ex = current_exception();
@@ -918,12 +779,6 @@ class spawn_entry_point
918779
throw;
919780
}
920781
# endif // defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER)
921-
# if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
922-
catch (const boost::coroutines::detail::forced_unwind&)
923-
{
924-
throw;
925-
}
926-
# endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
927782
catch (...)
928783
{
929784
exception_ptr ex = current_exception();
@@ -1102,14 +957,6 @@ template <typename Executor, typename F,
1102957
BOOST_ASIO_COMPLETION_TOKEN_FOR(typename detail::spawn_signature<
1103958
result_of_t<F(basic_yield_context<Executor>)>>::type) CompletionToken>
1104959
inline auto spawn(const Executor& ex, F&& function, CompletionToken&& token,
1105-
#if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1106-
constraint_t<
1107-
!is_same<
1108-
decay_t<CompletionToken>,
1109-
boost::coroutines::attributes
1110-
>::value
1111-
>,
1112-
#endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1113960
constraint_t<
1114961
is_executor<Executor>::value || execution::is_executor<Executor>::value
1115962
>)
@@ -1132,14 +979,6 @@ template <typename ExecutionContext, typename F,
1132979
result_of_t<F(basic_yield_context<
1133980
typename ExecutionContext::executor_type>)>>::type) CompletionToken>
1134981
inline auto spawn(ExecutionContext& ctx, F&& function, CompletionToken&& token,
1135-
#if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1136-
constraint_t<
1137-
!is_same<
1138-
decay_t<CompletionToken>,
1139-
boost::coroutines::attributes
1140-
>::value
1141-
>,
1142-
#endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1143982
constraint_t<
1144983
is_convertible<ExecutionContext&, execution_context&>::value
1145984
>)
@@ -1162,14 +1001,6 @@ template <typename Executor, typename F,
11621001
CompletionToken>
11631002
inline auto spawn(const basic_yield_context<Executor>& ctx,
11641003
F&& function, CompletionToken&& token,
1165-
#if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1166-
constraint_t<
1167-
!is_same<
1168-
decay_t<CompletionToken>,
1169-
boost::coroutines::attributes
1170-
>::value
1171-
>,
1172-
#endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
11731004
constraint_t<
11741005
is_executor<Executor>::value || execution::is_executor<Executor>::value
11751006
>)
@@ -1260,140 +1091,6 @@ inline auto spawn(const basic_yield_context<Executor>& ctx, allocator_arg_t,
12601091

12611092
#endif // defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER)
12621093

1263-
#if defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1264-
1265-
namespace detail {
1266-
1267-
template <typename Executor, typename Function, typename Handler>
1268-
class old_spawn_entry_point
1269-
{
1270-
public:
1271-
template <typename F, typename H>
1272-
old_spawn_entry_point(const Executor& ex, F&& f, H&& h)
1273-
: executor_(ex),
1274-
function_(static_cast<F&&>(f)),
1275-
handler_(static_cast<H&&>(h))
1276-
{
1277-
}
1278-
1279-
void operator()(spawned_thread_base* spawned_thread)
1280-
{
1281-
const basic_yield_context<Executor> yield(spawned_thread, executor_);
1282-
this->call(yield,
1283-
void_type<result_of_t<Function(basic_yield_context<Executor>)>>());
1284-
}
1285-
1286-
private:
1287-
void call(const basic_yield_context<Executor>& yield, void_type<void>)
1288-
{
1289-
function_(yield);
1290-
static_cast<Handler&&>(handler_)();
1291-
}
1292-
1293-
template <typename T>
1294-
void call(const basic_yield_context<Executor>& yield, void_type<T>)
1295-
{
1296-
static_cast<Handler&&>(handler_)(function_(yield));
1297-
}
1298-
1299-
Executor executor_;
1300-
Function function_;
1301-
Handler handler_;
1302-
};
1303-
1304-
inline void default_spawn_handler() {}
1305-
1306-
} // namespace detail
1307-
1308-
template <typename Function>
1309-
inline void spawn(Function&& function,
1310-
const boost::coroutines::attributes& attributes)
1311-
{
1312-
associated_executor_t<decay_t<Function>> ex(
1313-
(get_associated_executor)(function));
1314-
1315-
boost::asio::spawn(ex, static_cast<Function&&>(function), attributes);
1316-
}
1317-
1318-
template <typename Handler, typename Function>
1319-
void spawn(Handler&& handler, Function&& function,
1320-
const boost::coroutines::attributes& attributes,
1321-
constraint_t<
1322-
!is_executor<decay_t<Handler>>::value &&
1323-
!execution::is_executor<decay_t<Handler>>::value &&
1324-
!is_convertible<Handler&, execution_context&>::value>)
1325-
{
1326-
typedef associated_executor_t<decay_t<Handler>> executor_type;
1327-
executor_type ex((get_associated_executor)(handler));
1328-
1329-
(dispatch)(ex,
1330-
detail::spawned_thread_resumer(
1331-
detail::spawned_coroutine_thread::spawn(
1332-
detail::old_spawn_entry_point<executor_type,
1333-
decay_t<Function>, void (*)()>(
1334-
ex, static_cast<Function&&>(function),
1335-
&detail::default_spawn_handler), attributes)));
1336-
}
1337-
1338-
template <typename Executor, typename Function>
1339-
void spawn(basic_yield_context<Executor> ctx, Function&& function,
1340-
const boost::coroutines::attributes& attributes)
1341-
{
1342-
(dispatch)(ctx.get_executor(),
1343-
detail::spawned_thread_resumer(
1344-
detail::spawned_coroutine_thread::spawn(
1345-
detail::old_spawn_entry_point<Executor,
1346-
decay_t<Function>, void (*)()>(
1347-
ctx.get_executor(), static_cast<Function&&>(function),
1348-
&detail::default_spawn_handler), attributes)));
1349-
}
1350-
1351-
template <typename Function, typename Executor>
1352-
inline void spawn(const Executor& ex, Function&& function,
1353-
const boost::coroutines::attributes& attributes,
1354-
constraint_t<
1355-
is_executor<Executor>::value || execution::is_executor<Executor>::value
1356-
>)
1357-
{
1358-
boost::asio::spawn(boost::asio::strand<Executor>(ex),
1359-
static_cast<Function&&>(function), attributes);
1360-
}
1361-
1362-
template <typename Function, typename Executor>
1363-
inline void spawn(const strand<Executor>& ex, Function&& function,
1364-
const boost::coroutines::attributes& attributes)
1365-
{
1366-
boost::asio::spawn(boost::asio::bind_executor(
1367-
ex, &detail::default_spawn_handler),
1368-
static_cast<Function&&>(function), attributes);
1369-
}
1370-
1371-
#if !defined(BOOST_ASIO_NO_TS_EXECUTORS)
1372-
1373-
template <typename Function>
1374-
inline void spawn(const boost::asio::io_context::strand& s, Function&& function,
1375-
const boost::coroutines::attributes& attributes)
1376-
{
1377-
boost::asio::spawn(boost::asio::bind_executor(
1378-
s, &detail::default_spawn_handler),
1379-
static_cast<Function&&>(function), attributes);
1380-
}
1381-
1382-
#endif // !defined(BOOST_ASIO_NO_TS_EXECUTORS)
1383-
1384-
template <typename Function, typename ExecutionContext>
1385-
inline void spawn(ExecutionContext& ctx, Function&& function,
1386-
const boost::coroutines::attributes& attributes,
1387-
constraint_t<
1388-
is_convertible<ExecutionContext&, execution_context&>::value
1389-
>)
1390-
{
1391-
boost::asio::spawn(ctx.get_executor(),
1392-
static_cast<Function&&>(function), attributes);
1393-
}
1394-
1395-
#endif // defined(BOOST_ASIO_HAS_BOOST_COROUTINE)
1396-
13971094
} // namespace asio
13981095
} // namespace boost
13991096

0 commit comments

Comments
 (0)