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 class  lely::util::FiberFlag {
  SAVE_MASK = FIBER_SAVE_MASK , SAVE_FENV = FIBER_SAVE_FENV , SAVE_ERROR = FIBER_SAVE_ERROR , SAVE_ALL = FIBER_SAVE_ALL ,
  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. More...
 

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.

Enumeration Type Documentation

◆ FiberFlag

enum lely::util::FiberFlag
strong

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.

Enumerator
SAVE_MASK 

The fiber saves and restores the signal mask (only supported on POSIX platforms).

SAVE_FENV 

The fiber saves and restores the floating-point environment.

SAVE_ERROR 

The fiber saves and restores the error values (i.e., errno and GetLastError() on Windows).

SAVE_ALL 

The combination of FiberFlag::SAVE_MASK, FiberFlag::SAVE_FENV and FiberFlag::SAVE_ERROR that is supported by the platform.

GUARD_STACK 

The fiber adds a guard page when allocating the stack frame so that the kernel generates a SIGSEGV signal on stack overflow (only supported on those POSIX platforms where mmap() supports anonymous mappings).

Definition at line 56 of file fiber.hpp.