summaryrefslogtreecommitdiff
path: root/boost/coroutine/detail/coroutine_context.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/coroutine/detail/coroutine_context.hpp')
-rw-r--r--boost/coroutine/detail/coroutine_context.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/boost/coroutine/detail/coroutine_context.hpp b/boost/coroutine/detail/coroutine_context.hpp
new file mode 100644
index 0000000000..6c4ebb68b1
--- /dev/null
+++ b/boost/coroutine/detail/coroutine_context.hpp
@@ -0,0 +1,62 @@
+
+// Copyright Oliver Kowalke 2009.
+// 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)
+
+#ifndef BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H
+#define BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H
+
+#include <cstddef>
+
+#include <boost/assert.hpp>
+#include <boost/config.hpp>
+#include <boost/context/fcontext.hpp>
+
+#include <boost/coroutine/detail/config.hpp>
+#include <boost/coroutine/stack_context.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace coroutines {
+namespace detail {
+
+// class hold stack-context and coroutines execution-context
+class BOOST_COROUTINES_DECL coroutine_context
+
+{
+private:
+ stack_context stack_ctx_;
+ context::fcontext_t ctx_;
+
+public:
+ typedef void( * ctx_fn)( intptr_t);
+
+ // default ctor represents the current execution-context
+ coroutine_context();
+
+ // ctor creates a new execution-context running coroutine-fn `fn`
+ // `ctx_` will be allocated on top of the stack managed by parameter
+ // `stack_ctx`
+ coroutine_context( ctx_fn fn, stack_context const& stack_ctx);
+
+ coroutine_context( coroutine_context const&);
+
+ coroutine_context& operator=( coroutine_context const&);
+
+ intptr_t jump( coroutine_context &, intptr_t = 0, bool = true);
+
+ stack_context & stack_ctx()
+ { return stack_ctx_; }
+};
+
+}}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H