Lely core libraries  2.2.5
fiber.hpp File Reference

This header file is part of the utilities library; it contains the C++ interface for the fiber implementation. More...

#include <lely/libc/type_traits.hpp>
#include <lely/util/error.hpp>
#include <lely/util/fiber.h>
#include <utility>
Include dependency graph for fiber.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lely::util::detail::FiberData
 
class  lely::util::FiberThread
 Convenience class providing a RAII-style mechanism to ensure the fiber associated with the calling thread is intialized for the duration of a scoped block. More...
 
class  lely::util::Fiber
 A fiber. More...
 
class  lely::util::fiber_unwind
 The exception used by lely::util::Fiber::~Fiber() to terminate the callable object and unwind its stack. More...
 

Enumerations

enum  lely::util::FiberFlag {
  lely::util::FiberFlag::SAVE_MASK = FIBER_SAVE_MASK, lely::util::FiberFlag::SAVE_FENV = FIBER_SAVE_FENV, lely::util::FiberFlag::SAVE_ERROR = FIBER_SAVE_ERROR, lely::util::FiberFlag::SAVE_ALL = FIBER_SAVE_ALL,
  lely::util::FiberFlag::GUARD_STACK = FIBER_GUARD_STACK
}
 Specifies which properties of the calling environment are saved or restored by a fiber when it is suspended or resumed and how its stack is allocated.
 

Detailed Description

This header file is part of the utilities library; it contains the C++ interface for the fiber implementation.

The design of the C++ interface is based on the fiber class in Boost.Context. It is a wrapper around fiber_t* which tries to prevent accidentally resuming a running or terminated fiber. The API is designed to be a building block for higher level constructs. For example, a call/cc operator similar to the one in Scheme can be implemented as:

template <class F>
inline Fiber
callcc(F&& f) {
return Fiber(::std::forward<F>(f)).resume();
}
See also
lely/util/fiber.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file fiber.hpp.