rename asymmetric_coroutine<> to coroutine<>

This commit is contained in:
Oliver Kowalke 2015-06-22 19:27:46 +02:00
parent adcf0aa663
commit bf1a225780
6 changed files with 44 additions and 43 deletions

View File

@ -8,7 +8,8 @@
[section:asymmetric Asymmetric coroutine]
Two asymmetric coroutine types - __push_coro__ and __pull_coro__ - provide a
unidirectional transfer of data.
unidirectional transfer of data.
[note ['asymmetric_coroutine<>] is a typedef of __coro__.]
[heading __pull_coro__]
@ -25,7 +26,7 @@ context; it transfers no data.
__pull_coro__ provides input iterators (__pull_coro_it__) and __begin__/__end__
are overloaded. The increment-operation switches the context and transfers data.
typedef boost::coroutines2::asymmetric_coroutine<int> coro_t;
typedef boost::coroutines2::coroutine<int> coro_t;
coro_t::pull_type source(
[&](coro_t::push_type& sink){
@ -78,7 +79,7 @@ __push_coro__ provides output iterators (__push_coro_it__) and
__begin__/__end__ are overloaded. The increment-operation switches the context
and transfers data.
typedef boost::coroutines2::asymmetric_coroutine<std::string> coro_t;
typedef boost::coroutines2::coroutine<std::string> coro_t;
struct FinalEOL{
~FinalEOL(){
@ -168,7 +169,7 @@ still valid and a data value is available or __coro_fn__ has terminated
(__pull_coro__ is invalid; no data value available). Access to the transferred
data value is given by __pull_coro_get__.
typedef boost::coroutines2::asymmetric_coroutine<int> coro_t;
typedef boost::coroutines2::coroutine<int> coro_t;
coro_t::pull_type source( // constructor enters coroutine-function
[&](coro_t::push_type& sink){
@ -194,7 +195,7 @@ The main-context must call this __push_coro_op__ in order to transfer each data
value into the __coro_fn__.
Access to the transferred data value is given by __pull_coro_get__.
typedef boost::coroutines2::asymmetric_coroutine<int> coro_t;
typedef boost::coroutines2::coroutine<int> coro_t;
coro_t::push_type sink( // constructor does NOT enter coroutine-function
[&](coro_t::pull_type& source){
@ -217,7 +218,7 @@ Splitting-up the access of parameters from context switch function enables to
check if __pull_coro__ is valid after return from __pull_coro_op__, e.g.
__pull_coro__ has values and __coro_fn__ has not terminated.
typedef boost::coroutines2::asymmetric_coroutine<boost::tuple<int,int>> coro_t;
typedef boost::coroutines2::coroutine<boost::tuple<int,int>> coro_t;
coro_t::push_type sink(
[&](coro_t::pull_type& source){
@ -283,7 +284,7 @@ After unwinding, a __coro__ is complete.
};
{
typedef boost::coroutines2::asymmetric_coroutine<void>::push_type coro_t;
typedef boost::coroutines2::coroutine<void>::push_type coro_t;
coro_t::push_type sink(
[&](coro_t::pull_type& source){
@ -320,7 +321,7 @@ After unwinding, a __coro__ is complete.
__boost_coroutine__ provides output- and input-iterators using __boost_range__.
__pull_coro__ can be used via input-iterators using __begin__ and __end__.
typedef boost::coroutines2::asymmetric_coroutine< int > coro_t;
typedef boost::coroutines2::coroutine< int > coro_t;
int number=2,exponent=8;
coro_t::pull_type source(
@ -338,20 +339,20 @@ __pull_coro__ can be used via input-iterators using __begin__ and __end__.
output:
2 4 8 16 32 64 128 256
['asymmetric_coroutine<>::pull_type::iterator::operator++()] corresponds to
__pull_coro_op__; ['asymmetric_coroutine<>::pull_type::iterator::operator*()]
['coroutine<>::pull_type::iterator::operator++()] corresponds to
__pull_coro_op__; ['coroutine<>::pull_type::iterator::operator*()]
roughly corresponds to __pull_coro_get__. An iterator originally obtained from
__begin__ of an __pull_coro__ compares equal to an iterator obtained from
__end__ of that same __pull_coro__ instance when its __pull_coro_bool__ would
return `false`].
[note If `T` is a move-only type, then
['asymmetric_coroutine<T>::pull_type::iterator] may only be dereferenced once
['coroutine<T>::pull_type::iterator] may only be dereferenced once
before it is incremented again.]
Output-iterators can be created from __push_coro__.
typedef boost::coroutines2::asymmetric_coroutine<int> coro_t;
typedef boost::coroutines2::coroutine<int> coro_t;
coro_t::push_type sink(
[&](coro_t::pull_type& source){
@ -364,7 +365,7 @@ Output-iterators can be created from __push_coro__.
std::vector<int> v{1,1,2,3,5,8,13,21,34,55};
std::copy(begin(v),end(v),begin(sink));
['asymmetric_coroutine<>::push_type::iterator::operator*()] roughly
['coroutine<>::push_type::iterator::operator*()] roughly
corresponds to __push_coro_op__. An iterator originally obtained from
__begin__ of an __push_coro__ compares equal to an iterator obtained from
__end__ of that same __push_coro__ instance when its __push_coro_bool__ would
@ -381,12 +382,12 @@ resumed with __push_coro_op__, __pull_coro_op__).]
[section:pull_coro Class `asymmetric_coroutine<>::pull_type`]
[section:pull_coro Class `coroutine<>::pull_type`]
#include <boost/coroutine2/asymmetric_coroutine.hpp>
#include <boost/coroutine2/coroutine.hpp>
template< typename R >
class asymmetric_coroutine<>::pull_type
class coroutine<>::pull_type
{
public:
pull_type() noexcept;
@ -498,9 +499,9 @@ passed to the coroutine-function).]]
[heading `R get()`]
R asymmetric_coroutine<R,StackAllocator>::pull_type::get();
R& asymmetric_coroutine<R&,StackAllocator>::pull_type::get();
void asymmetric_coroutine<void,StackAllocator>::pull_type::get()=delete;
R coroutine<R,StackAllocator>::pull_type::get();
R& coroutine<R&,StackAllocator>::pull_type::get();
void coroutine<void,StackAllocator>::pull_type::get()=delete;
[variablelist
[[Preconditions:] [`*this` is not a __not_a_coro__.]]
@ -550,12 +551,12 @@ would return `false`.]]
[endsect]
[section:push_coro Class `asymmetric_coroutine<>::push_type`]
[section:push_coro Class `coroutine<>::push_type`]
#include <boost/coroutine2/asymmetric_coroutine.hpp>
#include <boost/coroutine2/coroutine.hpp>
template< typename Arg >
class asymmetric_coroutine<>::push_type
class coroutine<>::push_type
{
public:
push_type() noexcept;
@ -654,9 +655,9 @@ has returned (completed), the function returns `true`. Otherwise `false`.]]
[heading `push_type & operator()(Arg arg)`]
push_type& asymmetric_coroutine<Arg>::push_type::operator()(Arg);
push_type& asymmetric_coroutine<Arg&>::push_type::operator()(Arg&);
push_type& asymmetric_coroutine<void>::push_type::operator()();
push_type& coroutine<Arg>::push_type::operator()(Arg);
push_type& coroutine<Arg&>::push_type::operator()(Arg&);
push_type& coroutine<void>::push_type::operator()();
[variablelist
[[Preconditions:] [operator unspecified-bool-type() returns `true` for `*this`.]]

View File

@ -38,7 +38,7 @@
[def __stack__ ['stack]]
[def __tls__ ['thread-local-storage]]
[def __acoro__ ['asymmetric_coroutine<>]]
[def __acoro__ ['coroutine<>]]
[def __attrs__ ['attributes]]
[def __begin__ ['std::begin()]]
[def __bind__ ['boost::bind()]]
@ -55,15 +55,15 @@
[def __io_service__ ['boost::asio::io_sevice]]
[def __protected_allocator__ ['protected_fixedsize]]
[def __protected_fixedsize__ ['protected_fixedsize_stack]]
[def __pull_coro__ ['asymmetric_coroutine<>::pull_type]]
[def __pull_coro_bool__ ['asymmetric_coroutine<>::pull_type::operator bool]]
[def __pull_coro_get__ ['asymmetric_coroutine<>::pull_type::get()]]
[def __pull_coro_it__ ['asymmetric_coroutine<>::pull_type::iterator]]
[def __pull_coro_op__ ['asymmetric_coroutine<>::pull_type::operator()]]
[def __push_coro__ ['asymmetric_coroutine<>::push_type]]
[def __push_coro_bool__ ['asymmetric_coroutine<>::push_type::operator bool]]
[def __push_coro_it__ ['asymmetric_coroutine<>::push_type::iterator]]
[def __push_coro_op__ ['asymmetric_coroutine<>::push_type::operator()]]
[def __pull_coro__ ['coroutine<>::pull_type]]
[def __pull_coro_bool__ ['coroutine<>::pull_type::operator bool]]
[def __pull_coro_get__ ['coroutine<>::pull_type::get()]]
[def __pull_coro_it__ ['coroutine<>::pull_type::iterator]]
[def __pull_coro_op__ ['coroutine<>::pull_type::operator()]]
[def __push_coro__ ['coroutine<>::push_type]]
[def __push_coro_bool__ ['coroutine<>::push_type::operator bool]]
[def __push_coro_it__ ['coroutine<>::push_type::iterator]]
[def __push_coro_op__ ['coroutine<>::push_type::operator()]]
[def __segmented_allocator__ ['segmented]]
[def __segmented__ ['segmented_stack]]
[def __server__ ['server]]

View File

@ -83,8 +83,8 @@ coroutine results in undefined behaviour.]
As an example, the code below will result in undefined behaviour:
boost::coroutines2::asymmetric_coroutine<void>::push_type coro(
[&](boost::coroutines2::asymmetric_coroutine<void>::pull_type& yield){
boost::coroutines2::coroutine<void>::push_type coro(
[&](boost::coroutines2::coroutine<void>::pull_type& yield){
coro();
});
coro();

View File

@ -251,7 +251,7 @@ parser for parsed symbols.
}
};
typedef boost::coroutines2::asymmetric_coroutine< char > coro_t;
typedef boost::coroutines2::coroutine< char > coro_t;
int main() {
std::istringstream is("1+1");
@ -382,7 +382,7 @@ data structure.
node::create("e")));
}
typedef boost::coroutines2::asymmetric_coroutine<std::string> coro_t;
typedef boost::coroutines2::coroutine<std::string> coro_t;
// recursively walk the tree, delivering values in order
void traverse(node::ptr_t n,
@ -441,7 +441,7 @@ data structure.
This code shows how coroutines could be chained.
typedef boost::coroutines2::asymmetric_coroutine<std::string> coro_t;
typedef boost::coroutines2::coroutine<std::string> coro_t;
// deliver each line of input stream to sink as a separate string
void readlines(coro_t::push_type& sink,std::istream& in){

View File

@ -93,7 +93,7 @@ private:
}
};
typedef boost::coroutines2::asymmetric_coroutine< char > coro_t;
typedef boost::coroutines2::coroutine< char > coro_t;
int main() {
try {

View File

@ -22,13 +22,13 @@ namespace boost {
namespace coroutines2 {
template< typename T >
struct asymmetric_coroutine {
struct coroutine {
typedef detail::pull_coroutine< T > pull_type;
typedef detail::push_coroutine< T > push_type;
};
template< typename T >
using coroutine = asymmetric_coroutine< T >;
using asymmetric_coroutine = coroutine< T >;
}}