summaryrefslogtreecommitdiff
path: root/boost/context
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:18:43 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:18:43 +0900
commit5ce2ccf2f23c6d3de4c79f216f57ca6f2a18ed16 (patch)
treebbee48efb9867d19ac3fdd84ba714c7af326cd53 /boost/context
parentb8cf34c691623e4ec329053cbbf68522a855882d (diff)
downloadboost-5ce2ccf2f23c6d3de4c79f216f57ca6f2a18ed16.tar.gz
boost-5ce2ccf2f23c6d3de4c79f216f57ca6f2a18ed16.tar.bz2
boost-5ce2ccf2f23c6d3de4c79f216f57ca6f2a18ed16.zip
Imported Upstream version 1.68.0upstream/1.68.0
Diffstat (limited to 'boost/context')
-rw-r--r--boost/context/all.hpp15
-rw-r--r--boost/context/continuation_fcontext.hpp27
-rw-r--r--boost/context/continuation_ucontext.hpp34
-rw-r--r--boost/context/continuation_winfib.hpp34
-rw-r--r--boost/context/detail/exception.hpp10
-rw-r--r--boost/context/execution_context_v1.hpp20
-rw-r--r--boost/context/execution_context_v2.hpp27
-rw-r--r--boost/context/execution_context_v2_void.ipp20
-rw-r--r--boost/context/fiber_fcontext.hpp29
-rw-r--r--boost/context/fiber_ucontext.hpp36
-rw-r--r--boost/context/fiber_winfib.hpp39
11 files changed, 84 insertions, 207 deletions
diff --git a/boost/context/all.hpp b/boost/context/all.hpp
deleted file mode 100644
index efee26026a..0000000000
--- a/boost/context/all.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-// Copyright Oliver Kowalke 2016.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/context/continuation.hpp>
-#include <boost/context/fiber.hpp>
-#include <boost/context/fixedsize_stack.hpp>
-#include <boost/context/execution_context.hpp>
-#include <boost/context/pooled_fixedsize_stack.hpp>
-#include <boost/context/protected_fixedsize_stack.hpp>
-#include <boost/context/segmented_stack.hpp>
-#include <boost/context/stack_context.hpp>
-#include <boost/context/stack_traits.hpp>
diff --git a/boost/context/continuation_fcontext.hpp b/boost/context/continuation_fcontext.hpp
index 03f8f6a644..a16ea63e00 100644
--- a/boost/context/continuation_fcontext.hpp
+++ b/boost/context/continuation_fcontext.hpp
@@ -78,8 +78,11 @@ void context_entry( transfer_t t) noexcept {
t = jump_fcontext( t.fctx, nullptr);
// start executing
t.fctx = rec->run( t.fctx);
- } catch ( forced_unwind const& e) {
- t = { e.fctx, nullptr };
+ } catch ( forced_unwind const& ex) {
+ t = { ex.fctx, nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
BOOST_ASSERT( nullptr != t.fctx);
// destroy context-stack of `this`context on next context
@@ -294,30 +297,10 @@ public:
return nullptr == fctx_;
}
- bool operator==( continuation const& other) const noexcept {
- return fctx_ == other.fctx_;
- }
-
- bool operator!=( continuation const& other) const noexcept {
- return fctx_ != other.fctx_;
- }
-
bool operator<( continuation const& other) const noexcept {
return fctx_ < other.fctx_;
}
- bool operator>( continuation const& other) const noexcept {
- return other.fctx_ < fctx_;
- }
-
- bool operator<=( continuation const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( continuation const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
diff --git a/boost/context/continuation_ucontext.hpp b/boost/context/continuation_ucontext.hpp
index b2682cf47f..a1ad97f440 100644
--- a/boost/context/continuation_ucontext.hpp
+++ b/boost/context/continuation_ucontext.hpp
@@ -209,11 +209,20 @@ struct BOOST_CONTEXT_DECL activation_record_initializer {
};
struct forced_unwind {
- activation_record * from{ nullptr };
+ activation_record * from{ nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ bool caught{ false };
+#endif
forced_unwind( activation_record * from_) noexcept :
from{ from_ } {
}
+
+#ifndef BOOST_ASSERT_IS_VOID
+ ~forced_unwind() {
+ BOOST_ASSERT( caught);
+ }
+#endif
};
template< typename Ctx, typename StackAlloc, typename Fn >
@@ -259,6 +268,9 @@ public:
#endif
} catch ( forced_unwind const& ex) {
c = Ctx{ ex.from };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
// this context has finished its task
from = nullptr;
@@ -445,30 +457,10 @@ public:
return nullptr == ptr_ || ptr_->terminated;
}
- bool operator==( continuation const& other) const noexcept {
- return ptr_ == other.ptr_;
- }
-
- bool operator!=( continuation const& other) const noexcept {
- return ptr_ != other.ptr_;
- }
-
bool operator<( continuation const& other) const noexcept {
return ptr_ < other.ptr_;
}
- bool operator>( continuation const& other) const noexcept {
- return other.ptr_ < ptr_;
- }
-
- bool operator<=( continuation const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( continuation const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
diff --git a/boost/context/continuation_winfib.hpp b/boost/context/continuation_winfib.hpp
index a92463f326..b75cbec26c 100644
--- a/boost/context/continuation_winfib.hpp
+++ b/boost/context/continuation_winfib.hpp
@@ -185,11 +185,20 @@ struct BOOST_CONTEXT_DECL activation_record_initializer {
};
struct forced_unwind {
- activation_record * from{ nullptr };
+ activation_record * from{ nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ bool caught{ false };
+#endif
explicit forced_unwind( activation_record * from_) :
from{ from_ } {
}
+
+#ifndef BOOST_ASSERT_IS_VOID
+ ~forced_unwind() {
+ BOOST_ASSERT( caught);
+ }
+#endif
};
template< typename Ctx, typename StackAlloc, typename Fn >
@@ -230,6 +239,9 @@ public:
#endif
} catch ( forced_unwind const& ex) {
c = Ctx{ ex.from };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
// this context has finished its task
from = nullptr;
@@ -384,30 +396,10 @@ public:
return nullptr == ptr_ || ptr_->terminated;
}
- bool operator==( continuation const& other) const noexcept {
- return ptr_ == other.ptr_;
- }
-
- bool operator!=( continuation const& other) const noexcept {
- return ptr_ != other.ptr_;
- }
-
bool operator<( continuation const& other) const noexcept {
return ptr_ < other.ptr_;
}
- bool operator>( continuation const& other) const noexcept {
- return other.ptr_ < ptr_;
- }
-
- bool operator<=( continuation const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( continuation const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
diff --git a/boost/context/detail/exception.hpp b/boost/context/detail/exception.hpp
index 14b4ab5217..87abaf18b2 100644
--- a/boost/context/detail/exception.hpp
+++ b/boost/context/detail/exception.hpp
@@ -7,6 +7,7 @@
#ifndef BOOST_CONTEXT_DETAIL_EXCEPTION_H
#define BOOST_CONTEXT_DETAIL_EXCEPTION_H
+#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/context/detail/fcontext.hpp>
@@ -21,12 +22,21 @@ namespace detail {
struct forced_unwind {
fcontext_t fctx{ nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ bool caught{ false };
+#endif
forced_unwind() = default;
forced_unwind( fcontext_t fctx_) :
fctx( fctx_) {
}
+
+#ifndef BOOST_ASSERT_IS_VOID
+ ~forced_unwind() {
+ BOOST_ASSERT( caught);
+ }
+#endif
};
}}}
diff --git a/boost/context/execution_context_v1.hpp b/boost/context/execution_context_v1.hpp
index 73008e63ab..15d3cb3efe 100644
--- a/boost/context/execution_context_v1.hpp
+++ b/boost/context/execution_context_v1.hpp
@@ -440,30 +440,10 @@ public:
return nullptr == ptr_.get();
}
- bool operator==( execution_context const& other) const noexcept {
- return ptr_ == other.ptr_;
- }
-
- bool operator!=( execution_context const& other) const noexcept {
- return ptr_ != other.ptr_;
- }
-
bool operator<( execution_context const& other) const noexcept {
return ptr_ < other.ptr_;
}
- bool operator>( execution_context const& other) const noexcept {
- return other.ptr_ < ptr_;
- }
-
- bool operator<=( execution_context const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( execution_context const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, execution_context const& other) {
diff --git a/boost/context/execution_context_v2.hpp b/boost/context/execution_context_v2.hpp
index 22a5502603..3f76317eea 100644
--- a/boost/context/execution_context_v2.hpp
+++ b/boost/context/execution_context_v2.hpp
@@ -238,30 +238,10 @@ public:
return nullptr == fctx_;
}
- bool operator==( execution_context const& other) const noexcept {
- return fctx_ == other.fctx_;
- }
-
- bool operator!=( execution_context const& other) const noexcept {
- return fctx_ != other.fctx_;
- }
-
bool operator<( execution_context const& other) const noexcept {
return fctx_ < other.fctx_;
}
- bool operator>( execution_context const& other) const noexcept {
- return other.fctx_ < fctx_;
- }
-
- bool operator<=( execution_context const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( execution_context const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, execution_context const& other) {
@@ -385,8 +365,11 @@ void ecv2_context_etry( transfer_t t_) noexcept {
t = jump_fcontext( t_.fctx, nullptr);
// start executing
t = rec->run( t);
- } catch ( forced_unwind const& e) {
- t = { e.fctx, nullptr };
+ } catch ( forced_unwind const& ex) {
+ t = { ex.fctx, nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
BOOST_ASSERT( nullptr != t.fctx);
// destroy context-stack of `this`context on next context
diff --git a/boost/context/execution_context_v2_void.ipp b/boost/context/execution_context_v2_void.ipp
index f262a0c9c9..eb291d2225 100644
--- a/boost/context/execution_context_v2_void.ipp
+++ b/boost/context/execution_context_v2_void.ipp
@@ -205,30 +205,10 @@ public:
return nullptr == fctx_;
}
- bool operator==( execution_context const& other) const noexcept {
- return fctx_ == other.fctx_;
- }
-
- bool operator!=( execution_context const& other) const noexcept {
- return fctx_ != other.fctx_;
- }
-
bool operator<( execution_context const& other) const noexcept {
return fctx_ < other.fctx_;
}
- bool operator>( execution_context const& other) const noexcept {
- return other.fctx_ < fctx_;
- }
-
- bool operator<=( execution_context const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( execution_context const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, execution_context const& other) {
diff --git a/boost/context/fiber_fcontext.hpp b/boost/context/fiber_fcontext.hpp
index 9b792bc96b..170490ad1d 100644
--- a/boost/context/fiber_fcontext.hpp
+++ b/boost/context/fiber_fcontext.hpp
@@ -78,8 +78,11 @@ void fiber_entry( transfer_t t) noexcept {
t = jump_fcontext( t.fctx, nullptr);
// start executing
t.fctx = rec->run( t.fctx);
- } catch ( forced_unwind const& e) {
- t = { e.fctx, nullptr };
+ } catch ( forced_unwind const& ex) {
+ t = { ex.fctx, nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
BOOST_ASSERT( nullptr != t.fctx);
// destroy context-stack of `this`context on next context
@@ -308,30 +311,10 @@ public:
return nullptr == fctx_;
}
- bool operator==( fiber const& other) const noexcept {
- return fctx_ == other.fctx_;
- }
-
- bool operator!=( fiber const& other) const noexcept {
- return fctx_ != other.fctx_;
- }
-
bool operator<( fiber const& other) const noexcept {
return fctx_ < other.fctx_;
}
- bool operator>( fiber const& other) const noexcept {
- return other.fctx_ < fctx_;
- }
-
- bool operator<=( fiber const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( fiber const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
@@ -352,6 +335,8 @@ void swap( fiber & l, fiber & r) noexcept {
l.swap( r);
}
+typedef fiber fiber_context;
+
}}
#if defined(BOOST_MSVC)
diff --git a/boost/context/fiber_ucontext.hpp b/boost/context/fiber_ucontext.hpp
index ae62389526..6484364784 100644
--- a/boost/context/fiber_ucontext.hpp
+++ b/boost/context/fiber_ucontext.hpp
@@ -209,11 +209,20 @@ struct BOOST_CONTEXT_DECL fiber_activation_record_initializer {
};
struct forced_unwind {
- fiber_activation_record * from{ nullptr };
+ fiber_activation_record * from{ nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ bool caught{ false };
+#endif
forced_unwind( fiber_activation_record * from_) noexcept :
from{ from_ } {
}
+
+#ifndef BOOST_ASSERT_IS_VOID
+ ~forced_unwind() {
+ BOOST_ASSERT( caught);
+ }
+#endif
};
template< typename Ctx, typename StackAlloc, typename Fn >
@@ -259,6 +268,9 @@ public:
#endif
} catch ( forced_unwind const& ex) {
c = Ctx{ ex.from };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
// this context has finished its task
from = nullptr;
@@ -462,30 +474,10 @@ public:
return nullptr == ptr_ || ptr_->terminated;
}
- bool operator==( fiber const& other) const noexcept {
- return ptr_ == other.ptr_;
- }
-
- bool operator!=( fiber const& other) const noexcept {
- return ptr_ != other.ptr_;
- }
-
bool operator<( fiber const& other) const noexcept {
return ptr_ < other.ptr_;
}
- bool operator>( fiber const& other) const noexcept {
- return other.ptr_ < ptr_;
- }
-
- bool operator<=( fiber const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( fiber const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
@@ -506,6 +498,8 @@ void swap( fiber & l, fiber & r) noexcept {
l.swap( r);
}
+typedef fiber fiber_context;
+
}}
#ifdef BOOST_HAS_ABI_HEADERS
diff --git a/boost/context/fiber_winfib.hpp b/boost/context/fiber_winfib.hpp
index cfd570a2e7..f2612fd8e3 100644
--- a/boost/context/fiber_winfib.hpp
+++ b/boost/context/fiber_winfib.hpp
@@ -85,8 +85,7 @@ struct BOOST_CONTEXT_DECL fiber_activation_record {
#else
fiber = ::ConvertThreadToFiber( nullptr);
if ( BOOST_UNLIKELY( nullptr == fiber) ) {
- DWORD err = ::GetLastError();
- BOOST_ASSERT( ERROR_ALREADY_FIBER == err);
+ BOOST_ASSERT( ERROR_ALREADY_FIBER == ::GetLastError());
fiber = ::GetCurrentFiber();
BOOST_ASSERT( nullptr != fiber);
BOOST_ASSERT( reinterpret_cast< LPVOID >( 0x1E00) != fiber);
@@ -185,11 +184,20 @@ struct BOOST_CONTEXT_DECL fiber_activation_record_initializer {
};
struct forced_unwind {
- fiber_activation_record * from{ nullptr };
+ fiber_activation_record * from{ nullptr };
+#ifndef BOOST_ASSERT_IS_VOID
+ bool caught{ false };
+#endif
explicit forced_unwind( fiber_activation_record * from_) :
from{ from_ } {
}
+
+#ifndef BOOST_ASSERT_IS_VOID
+ ~forced_unwind() {
+ BOOST_ASSERT( caught);
+ }
+#endif
};
template< typename Ctx, typename StackAlloc, typename Fn >
@@ -230,6 +238,9 @@ public:
#endif
} catch ( forced_unwind const& ex) {
c = Ctx{ ex.from };
+#ifndef BOOST_ASSERT_IS_VOID
+ const_cast< forced_unwind & >( ex).caught = true;
+#endif
}
// this context has finished its task
from = nullptr;
@@ -396,30 +407,10 @@ public:
return nullptr == ptr_ || ptr_->terminated;
}
- bool operator==( fiber const& other) const noexcept {
- return ptr_ == other.ptr_;
- }
-
- bool operator!=( fiber const& other) const noexcept {
- return ptr_ != other.ptr_;
- }
-
bool operator<( fiber const& other) const noexcept {
return ptr_ < other.ptr_;
}
- bool operator>( fiber const& other) const noexcept {
- return other.ptr_ < ptr_;
- }
-
- bool operator<=( fiber const& other) const noexcept {
- return ! ( * this > other);
- }
-
- bool operator>=( fiber const& other) const noexcept {
- return ! ( * this < other);
- }
-
template< typename charT, class traitsT >
friend std::basic_ostream< charT, traitsT > &
operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
@@ -440,6 +431,8 @@ void swap( fiber & l, fiber & r) noexcept {
l.swap( r);
}
+typedef fiber fiber_context;
+
}}
#if defined(BOOST_MSVC)