You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

344 lines
15 KiB

  1. Index: boost_1_65_0/boost/context/continuation_fcontext.hpp
  2. ===================================================================
  3. --- boost_1_65_0.orig/boost/context/continuation_fcontext.hpp
  4. +++ boost_1_65_0/boost/context/continuation_fcontext.hpp
  5. @@ -95,7 +95,7 @@ transfer_t context_ontop( transfer_t t)
  6. t.data = nullptr;
  7. Ctx c{ t.fctx };
  8. // execute function, pass continuation via reference
  9. - fn( std::move( c) );
  10. + c = fn( std::move( c) );
  11. #if defined(BOOST_NO_CXX14_STD_EXCHANGE)
  12. return { exchange( c.fctx_, nullptr), nullptr };
  13. #else
  14. Index: boost_1_65_0/boost/context/continuation_ucontext.hpp
  15. ===================================================================
  16. --- boost_1_65_0.orig/boost/context/continuation_ucontext.hpp
  17. +++ boost_1_65_0/boost/context/continuation_ucontext.hpp
  18. @@ -84,18 +84,18 @@ static void entry_func( void * data) noe
  19. struct BOOST_CONTEXT_DECL activation_record {
  20. thread_local static activation_record * current_rec;
  21. - ucontext_t uctx{};
  22. - stack_context sctx{};
  23. - bool main_ctx{ true };
  24. - activation_record * from{ nullptr };
  25. - std::function< void(activation_record*&) > ontop{};
  26. - bool terminated{ false };
  27. - bool force_unwind{ false };
  28. + ucontext_t uctx{};
  29. + stack_context sctx{};
  30. + bool main_ctx{ true };
  31. + activation_record * from{ nullptr };
  32. + std::function< activation_record*(activation_record*&) > ontop{};
  33. + bool terminated{ false };
  34. + bool force_unwind{ false };
  35. #if defined(BOOST_USE_ASAN)
  36. - void * fake_stack{ nullptr };
  37. - void * stack_bottom{ nullptr };
  38. - std::size_t stack_size{ 0 };
  39. - bool started{ false };
  40. + void * fake_stack{ nullptr };
  41. + void * stack_bottom{ nullptr };
  42. + std::size_t stack_size{ 0 };
  43. + bool started{ false };
  44. #endif
  45. static activation_record *& current() noexcept;
  46. @@ -168,20 +168,30 @@ struct BOOST_CONTEXT_DECL activation_rec
  47. current()->ontop = std::bind(
  48. [](typename std::decay< Fn >::type & fn, activation_record *& ptr){
  49. Ctx c{ ptr };
  50. - fn( std::move( c) );
  51. + c = fn( std::move( c) );
  52. if ( ! c) {
  53. ptr = nullptr;
  54. }
  55. +#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
  56. + return exchange( c.ptr_, nullptr);
  57. +#else
  58. + return std::exchange( c.ptr_, nullptr);
  59. +#endif
  60. },
  61. std::forward< Fn >( fn),
  62. std::placeholders::_1);
  63. #else
  64. current()->ontop = [fn=std::forward<Fn>(fn)](activation_record *& ptr){
  65. Ctx c{ ptr };
  66. - fn( std::move( c) );
  67. + c = fn( std::move( c) );
  68. if ( ! c) {
  69. ptr = nullptr;
  70. }
  71. +#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
  72. + return exchange( c.ptr_, nullptr);
  73. +#else
  74. + return std::exchange( c.ptr_, nullptr);
  75. +#endif
  76. };
  77. #endif
  78. #if defined(BOOST_USE_SEGMENTED_STACKS)
  79. @@ -408,7 +418,7 @@ public:
  80. if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
  81. throw detail::forced_unwind{ ptr};
  82. } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
  83. - detail::activation_record::current()->ontop( ptr);
  84. + ptr = detail::activation_record::current()->ontop( ptr);
  85. detail::activation_record::current()->ontop = nullptr;
  86. }
  87. return continuation{ ptr };
  88. @@ -426,7 +436,7 @@ public:
  89. if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
  90. throw detail::forced_unwind{ ptr};
  91. } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
  92. - detail::activation_record::current()->ontop( ptr);
  93. + ptr = detail::activation_record::current()->ontop( ptr);
  94. detail::activation_record::current()->ontop = nullptr;
  95. }
  96. return continuation{ ptr };
  97. Index: boost_1_65_0/boost/context/continuation_winfib.hpp
  98. ===================================================================
  99. --- boost_1_65_0.orig/boost/context/continuation_winfib.hpp
  100. +++ boost_1_65_0/boost/context/continuation_winfib.hpp
  101. @@ -65,13 +65,13 @@ static VOID WINAPI entry_func( LPVOID da
  102. struct BOOST_CONTEXT_DECL activation_record {
  103. thread_local static activation_record * current_rec;
  104. - LPVOID fiber{ nullptr };
  105. - stack_context sctx{};
  106. - bool main_ctx{ true };
  107. - activation_record * from{ nullptr };
  108. - std::function< void(activation_record*&) > ontop{};
  109. - bool terminated{ false };
  110. - bool force_unwind{ false };
  111. + LPVOID fiber{ nullptr };
  112. + stack_context sctx{};
  113. + bool main_ctx{ true };
  114. + activation_record * from{ nullptr };
  115. + std::function< activation_record*(activation_record*&) > ontop{};
  116. + bool terminated{ false };
  117. + bool force_unwind{ false };
  118. static activation_record *& current() noexcept;
  119. @@ -142,20 +142,30 @@ struct BOOST_CONTEXT_DECL activation_rec
  120. current()->ontop = std::bind(
  121. [](typename std::decay< Fn >::type & fn, activation_record *& ptr){
  122. Ctx c{ ptr };
  123. - fn( std::move( c) );
  124. + c = fn( std::move( c) );
  125. if ( ! c) {
  126. ptr = nullptr;
  127. }
  128. +#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
  129. + return exchange( c.ptr_, nullptr);
  130. +#else
  131. + return std::exchange( c.ptr_, nullptr);
  132. +#endif
  133. },
  134. std::forward< Fn >( fn),
  135. std::placeholders::_1);
  136. #else
  137. current()->ontop = [fn=std::forward<Fn>(fn)](activation_record *& ptr){
  138. Ctx c{ ptr };
  139. - fn( std::move( c) );
  140. + c = fn( std::move( c) );
  141. if ( ! c) {
  142. ptr = nullptr;
  143. }
  144. +#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
  145. + return exchange( c.ptr_, nullptr);
  146. +#else
  147. + return std::exchange( c.ptr_, nullptr);
  148. +#endif
  149. };
  150. #endif
  151. // context switch
  152. @@ -336,7 +346,7 @@ public:
  153. if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
  154. throw detail::forced_unwind{ ptr};
  155. } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
  156. - detail::activation_record::current()->ontop( ptr);
  157. + ptr = detail::activation_record::current()->ontop( ptr);
  158. detail::activation_record::current()->ontop = nullptr;
  159. }
  160. return continuation{ ptr };
  161. @@ -354,7 +364,7 @@ public:
  162. if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
  163. throw detail::forced_unwind{ ptr};
  164. } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
  165. - detail::activation_record::current()->ontop( ptr);
  166. + ptr = detail::activation_record::current()->ontop( ptr);
  167. detail::activation_record::current()->ontop = nullptr;
  168. }
  169. return continuation{ ptr };
  170. Index: boost_1_65_0/boost/thread/win32/condition_variable.hpp
  171. ===================================================================
  172. --- boost_1_65_0.orig/boost/thread/win32/condition_variable.hpp
  173. +++ boost_1_65_0/boost/thread/win32/condition_variable.hpp
  174. @@ -211,7 +211,7 @@ namespace boost
  175. {}
  176. #endif
  177. - void remove_waiter()
  178. + void remove_waiter_and_reset()
  179. {
  180. if (entry) {
  181. boost::lock_guard<boost::mutex> internal_lock(internal_mutex);
  182. @@ -221,7 +221,7 @@ namespace boost
  183. }
  184. ~entry_manager() BOOST_NOEXCEPT_IF(false)
  185. {
  186. - remove_waiter();
  187. + remove_waiter_and_reset();
  188. }
  189. list_entry* operator->()
  190. @@ -250,7 +250,7 @@ namespace boost
  191. woken=entry->woken();
  192. }
  193. // do it here to avoid throwing on the destructor
  194. - entry->remove_waiter();
  195. + entry.remove_waiter_and_reset();
  196. locker.lock();
  197. return woken;
  198. }
  199. Index: boost_1_65_0/libs/context/doc/callcc.qbk
  200. ===================================================================
  201. --- boost_1_65_0.orig/libs/context/doc/callcc.qbk
  202. +++ boost_1_65_0/libs/context/doc/callcc.qbk
  203. @@ -176,6 +176,7 @@ return `void`.
  204. c=c.resume_with([&data](ctx::continuation && c){
  205. std::cout << "f2: entered: " << data << std::endl;
  206. data=-1;
  207. + return std::move( c);
  208. });
  209. std::cout << "f1: returned third time" << std::endl;
  210. @@ -221,6 +222,7 @@ an exception.
  211. c = c.resume_with(
  212. [](ctx::continuation && c){
  213. throw my_exception(std::move(c),"abc");
  214. + return std::move( c);
  215. });
  216. output:
  217. @@ -527,11 +529,11 @@ e.g. ['continuation::operator bool()] re
  218. [variablelist
  219. [[Effects:] [Captures current continuation and resumes `*this`.
  220. -The function `resume_with`, is used to execute function `fn` in continuation
  221. +The function `resume_with`, is used to execute function `fn` in the execution context of
  222. `*this` (e.g. the stack frame of `fn` is allocated on stack of `*this`).]]
  223. [[Returns:] [The continuation representing the continuation that has been
  224. suspended.]]
  225. -[[Note:] [Function `fn` needs to return void.]]
  226. +[[Note:] [Function `fn` needs to return `continuation`.]]
  227. [[Note:] [The returned continuation indicates if the suspended continuation has
  228. terminated (return from context-function) via `bool operator()`.]]
  229. ]
  230. Index: boost_1_65_0/libs/context/example/ontop.cpp
  231. ===================================================================
  232. --- boost_1_65_0.orig/libs/context/example/ontop.cpp
  233. +++ boost_1_65_0/libs/context/example/ontop.cpp
  234. @@ -32,6 +32,7 @@ int main() {
  235. c = c.resume_with( [&data](ctx::continuation && c){
  236. std::cout << "f2: entered: " << data << std::endl;
  237. data = -1;
  238. + return std::move( c);
  239. });
  240. std::cout << "f1: returned third time" << std::endl;
  241. std::cout << "main: done" << std::endl;
  242. Index: boost_1_65_0/libs/context/example/ontop_void.cpp
  243. ===================================================================
  244. --- boost_1_65_0.orig/libs/context/example/ontop_void.cpp
  245. +++ boost_1_65_0/libs/context/example/ontop_void.cpp
  246. @@ -21,8 +21,9 @@ ctx::continuation f1( ctx::continuation
  247. return std::move( c);
  248. }
  249. -void f2( ctx::continuation && c) {
  250. +ctx::continuation f2( ctx::continuation && c) {
  251. std::cout << "f2: entered" << std::endl;
  252. + return std::move( c);
  253. }
  254. int main() {
  255. Index: boost_1_65_0/libs/context/example/throw.cpp
  256. ===================================================================
  257. --- boost_1_65_0.orig/libs/context/example/throw.cpp
  258. +++ boost_1_65_0/libs/context/example/throw.cpp
  259. @@ -38,6 +38,7 @@ int main() {
  260. c = c.resume_with(
  261. [](ctx::continuation && c){
  262. throw my_exception(std::move( c), "abc");
  263. + return std::move( c);
  264. });
  265. std::cout << "main: done" << std::endl;
  266. Index: boost_1_65_0/libs/context/test/test_callcc.cpp
  267. ===================================================================
  268. --- boost_1_65_0.orig/libs/context/test/test_callcc.cpp
  269. +++ boost_1_65_0/libs/context/test/test_callcc.cpp
  270. @@ -252,6 +252,7 @@ void test_ontop() {
  271. c = c.resume_with(
  272. [&i](ctx::continuation && c){
  273. i -= 10;
  274. + return std::move( c);
  275. });
  276. BOOST_CHECK( c);
  277. BOOST_CHECK_EQUAL( i, 200);
  278. @@ -266,6 +267,7 @@ void test_ontop() {
  279. c = c.resume_with(
  280. [&c1](ctx::continuation && c){
  281. c1 = std::move( c);
  282. + return std::move( c);
  283. });
  284. }
  285. }
  286. @@ -290,7 +292,8 @@ void test_ontop_exception() {
  287. const char * what = "hello world";
  288. c.resume_with(
  289. [what](ctx::continuation && c){
  290. - throw my_exception( std::move( c), what);
  291. + throw my_exception( std::move( c), what);
  292. + return std::move( c);
  293. });
  294. BOOST_CHECK_EQUAL( 3, value1);
  295. BOOST_CHECK_EQUAL( std::string( what), value2);
  296. Index: boost_1_65_0/libs/fiber/src/context.cpp
  297. ===================================================================
  298. --- boost_1_65_0.orig/libs/fiber/src/context.cpp
  299. +++ boost_1_65_0/libs/fiber/src/context.cpp
  300. @@ -145,6 +145,7 @@ context::resume() noexcept {
  301. // pass pointer to the context that resumes `this`
  302. c_.resume_with([prev](boost::context::continuation && c){
  303. prev->c_ = std::move( c);
  304. + return boost::context::continuation{};
  305. });
  306. }
  307. @@ -158,6 +159,7 @@ context::resume( detail::spinlock_lock &
  308. c_.resume_with([prev,&lk](boost::context::continuation && c){
  309. prev->c_ = std::move( c);
  310. lk.unlock();
  311. + return boost::context::continuation{};
  312. });
  313. }
  314. @@ -171,6 +173,7 @@ context::resume( context * ready_ctx) no
  315. c_.resume_with([prev,ready_ctx](boost::context::continuation && c){
  316. prev->c_ = std::move( c);
  317. context::active()->schedule( ready_ctx);
  318. + return boost::context::continuation{};
  319. });
  320. }
  321. @@ -218,6 +221,7 @@ context::suspend_with_cc() noexcept {
  322. // pass pointer to the context that resumes `this`
  323. return c_.resume_with([prev](boost::context::continuation && c){
  324. prev->c_ = std::move( c);
  325. + return boost::context::continuation{};
  326. });
  327. }