| Home | Libraries | People | FAQ | More

#### Class `coroutine<>::pull_type`

    #include <boost/coroutine/coroutine.hpp>

    template< typename R >
    class coroutine<>::pull_type
    {
    public:
        pull_type();

        template<
            typename Fn,
            typename StackAllocator = stack_allocator,
            typename Allocator = std::allocator< coroutine >
        >
        pull_type( Fn fn, attributes const& attr = attributes(),
                   StackAllocator const& stack_alloc = StackAllocator(),
                   Allocator const& alloc = Allocator() );

        template<
            typename Fn,
            typename StackAllocator = stack_allocator,
            typename Allocator = std::allocator< coroutine >
        >
        pull_type( Fn && fn, attributes const& attr = attributes(),
                   StackAllocator stack_alloc = StackAllocator(),
                   Allocator const& alloc = Allocator() );

        pull_type( pull_type && other);

        pull_type & operator=( pull_type && other);

        operator unspecified-bool-type() const;

        bool operator!() const;

        void swap( pull_type & other);

        bool empty() const;

        pull_type & operator()();

        bool has_result() const;

        R get() const;
    };

    template< typename R >
    void swap( pull_type< R > & l, pull_type< R > & r);

    template< typename R >
    range_iterator< pull_type< R > >::type begin( pull_type< R > &);

    template< typename R >
    range_iterator< pull_type< R > >::type end( pull_type< R > &);

###### `pull_type()`

Effects:

  Creates a coroutine representing not-a-coroutine.

Throws:

  Nothing.

###### `template< typename Fn, typename StackAllocator, typename Allocator > pull_type( Fn fn, attributes const& attr, StackAllocator const& stack_alloc, Allocator const& alloc)`

Preconditions:

  `size` > minimum_stacksize(), `size` < maximum_stacksize() when ! is_stack_unbound().

Effects:

  Creates a coroutine which will execute `fn`. Argument `attr` determines stack clean-up and preserving floating-point registers. For allocating/deallocating the stack `stack_alloc` is used and internal data are allocated by Allocator.

Throws:

  Exceptions thrown inside coroutine-function.

###### `template< typename Fn, typename StackAllocator, typename Allocator > pull_type( Fn && fn, attributes const& attr, StackAllocator const& stack_alloc, Allocator const& alloc)`

Preconditions:

  `size` > minimum_stacksize(), `size` < maximum_stacksize() when ! is_stack_unbound().

Effects:

  Creates a coroutine which will execute `fn`. Argument `attr` determines stack clean-up and preserving floating-point registers. For allocating/deallocating the stack `stack_alloc` is used and internal data are allocated by Allocator.

Throws:

  Exceptions thrown inside coroutine-function.

###### `pull_type( pull_type && other)`

Effects:

  Moves the internal data of `other` to `*this`. `other` becomes not-a-coroutine.

Throws:

  Nothing.

###### `pull_type & operator=( pull_type && other)`

Effects:

  Destroys the internal data of `*this` and moves the internal data of `other` to `*this`. `other` becomes not-a-coroutine.

Throws:

  Nothing.

###### `operator unspecified-bool-type() const`

Returns:

  If `*this` refers to not-a-coroutine or the coroutine-function has returned (completed), the function returns false. Otherwise true.

Throws:

  Nothing.

###### `bool operator!() const`

Returns:

  If `*this` refers to not-a-coroutine or the coroutine-function has returned (completed), the function returns true. Otherwise false.

Throws:

  Nothing.

###### `bool empty()`

Returns:

  If `*this` refers to not-a-coroutine, the function returns true. Otherwise false.

Throws:

  Nothing.

###### `pull_type<> & operator()()`

Preconditions:

  `*this` is not a not-a-coroutine.

Effects:

  Execution control is transferred to coroutine-function (no parameter are passed to the coroutine-function).

Throws:

  Exceptions thrown inside coroutine-function.

###### `bool has_result()`

Preconditions:

  `*this` is not a not-a-coroutine.

Returns:

  If `*this` has a, the function returns true. Otherwise false.

Throws:

  Nothing.

###### `R get()()`

    R    coroutine<R>::pull_type::get();
    R&   coroutine<R&>::pull_type::get();
    void coroutine<void>pull_type::get()=delete;

Preconditions:

  `*this` is not a not-a-coroutine.

Returns:

  Returns data transferred from coroutine-function via boost::coroutines::coroutine<>::push_type::operator().

Throws:

  Nothing.

###### `void swap( pull_type & other)`

Effects:

  Swaps the internal data from `*this` with the values of `other`.

Throws:

  Nothing.

###### Non-member function `swap()`

    template< typename R >
    void swap( pull_type< R > & l, pull_type< R > & r);

Effects:

  As if 'l.swap( r)'.

###### Non-member function `begin( pull_type< R > &)`

    template< typename R >
    range_iterator< pull_type< R > >::type begin( pull_type< R > &);

Returns:

  Returns a range-iterator (input-iterator).

###### Non-member function `end( pull_type< R > &)`

    template< typename R >
    range_iterator< pull_type< R > >::type end( pull_type< R > &);

Returns:

  Returns a end range-iterator (input-iterator).