coroutines

#include <hpx/coroutines/thread_enums.hpp>

namespace hpx
namespace threads

Enums

enum thread_state_enum

The thread_state_enum enumerator encodes the current state of a thread instance

Values:

unknown = 0
active = 1

thread is currently active (running, has resources)

pending = 2

thread is pending (ready to run, but no hardware resource available)

suspended = 3

thread has been suspended (waiting for synchronization event, but still known and under control of the thread-manager)

depleted = 4

thread has been depleted (deeply suspended, it is not known to the thread-manager)

terminated = 5

thread has been stopped an may be garbage collected

staged = 6

this is not a real thread state, but allows to reference staged task descriptions, which eventually will be converted into thread objects

pending_do_not_schedule = 7
pending_boost = 8
enum thread_priority

This enumeration lists all possible thread-priorities for HPX threads.

Values:

thread_priority_unknown = -1
thread_priority_default = 0

Will assign the priority of the task to the default (normal) priority.

thread_priority_low = 1

Task goes onto a special low priority queue and will not be executed until all high/normal priority tasks are done, even if they are added after the low priority task.

thread_priority_normal = 2

Task will be executed when it is taken from the normal priority queue, this is usually a first in-first-out ordering of tasks (depending on scheduler choice). This is the default priority.

thread_priority_high_recursive = 3

The task is a high priority task and any child tasks spawned by this task will be made high priority as well - unless they are specifically flagged as non default priority.

thread_priority_boost = 4

Same as thread_priority_high except that the thread will fall back to thread_priority_normal if resumed after being suspended.

thread_priority_high = 5

Task goes onto a special high priority queue and will be executed before normal/low priority tasks are taken (some schedulers modify the behavior slightly and the documentation for those should be consulted).

thread_priority_bound = 6

Task goes onto a special high priority queue and will never be stolen by another thread after initial assignment. This should be used for thread placement tasks such as OpenMP type for loops.

enum thread_state_ex_enum

The thread_state_ex_enum enumerator encodes the reason why a thread is being restarted

Values:

wait_unknown = 0
wait_signaled = 1

The thread has been signaled.

wait_timeout = 2

The thread has been reactivated after a timeout

wait_terminate = 3

The thread needs to be terminated.

wait_abort = 4

The thread needs to be aborted.

enum thread_stacksize

A thread_stacksize references any of the possible stack-sizes for HPX threads.

Values:

thread_stacksize_unknown = -1
thread_stacksize_small = 1

use small stack size

thread_stacksize_medium = 2

use medium sized stack size

thread_stacksize_large = 3

use large stack size

thread_stacksize_huge = 4

use very large stack size

thread_stacksize_nostack = 5

this thread does not suspend (does not need a stack)

thread_stacksize_current = 6

use size of current thread’s stack

thread_stacksize_default = thread_stacksize_small

use default stack size

thread_stacksize_minimal = thread_stacksize_small

use minimally stack size

thread_stacksize_maximal = thread_stacksize_huge

use maximally stack size

enum thread_schedule_hint_mode

The type of hint given when creating new tasks.

Values:

thread_schedule_hint_mode_none = 0
thread_schedule_hint_mode_thread = 1
thread_schedule_hint_mode_numa = 2

Functions

char const *get_thread_state_name(thread_state_enum state)

Returns the name of the given state.

Get the readable string representing the name of the given thread_state constant.

Parameters
  • state: this represents the thread state.

char const *get_thread_priority_name(thread_priority priority)

Return the thread priority name.

Get the readable string representing the name of the given thread_priority constant.

Parameters
  • this: represents the thread priority.

char const *get_thread_state_ex_name(thread_state_ex_enum state)

Get the readable string representing the name of the given thread_state_ex_enum constant.

char const *get_thread_state_name(thread_state state)

Get the readable string representing the name of the given thread_state constant.

char const *get_stack_size_name(std::ptrdiff_t size)

Returns the stack size name.

Get the readable string representing the given stack size constant.

Parameters
  • size: this represents the stack size

struct thread_schedule_hint

Public Functions

thread_schedule_hint()
thread_schedule_hint(std::int16_t thread_hint)
thread_schedule_hint(thread_schedule_hint_mode mode, std::int16_t hint)

Public Members

thread_schedule_hint_mode mode
std::int16_t hint

#include <hpx/coroutines/coroutine.hpp>

namespace hpx
namespace threads
namespace coroutines
class coroutine

Public Types

using impl_type = detail::coroutine_impl
using thread_id_type = impl_type::thread_id_type
using result_type = impl_type::result_type
using arg_type = impl_type::arg_type
using functor_type = util::unique_function_nonser<result_type(arg_type)>

Public Functions

coroutine(functor_type &&f, thread_id_type id, std::ptrdiff_t stack_size = detail::default_stack_size)
coroutine(coroutine const &src)
coroutine &operator=(coroutine const &src)
coroutine(coroutine &&src)
coroutine &operator=(coroutine &&src)
thread_id_type get_thread_id() const
std::size_t get_thread_data() const
std::size_t set_thread_data(std::size_t data)
void rebind(functor_type &&f, thread_id_type id)
result_type operator()(arg_type arg = arg_type())
bool is_ready() const
std::ptrdiff_t get_available_stack_space()
impl_type *impl()

Private Members

impl_type impl_

#include <hpx/coroutines/stackless_coroutine.hpp>

namespace hpx
namespace threads
namespace coroutines
class stackless_coroutine

Public Types

using thread_id_type = hpx::threads::thread_id
using result_type = std::pair<thread_state_enum, thread_id_type>
using arg_type = thread_state_ex_enum
using functor_type = util::unique_function_nonser<result_type(arg_type)>

Public Functions

stackless_coroutine(functor_type &&f, thread_id_type id, std::ptrdiff_t stack_size = default_stack_size)
~stackless_coroutine()
stackless_coroutine(stackless_coroutine const &src)
stackless_coroutine &operator=(stackless_coroutine const &src)
stackless_coroutine(stackless_coroutine &&src)
stackless_coroutine &operator=(stackless_coroutine &&src)
thread_id_type get_thread_id() const
std::size_t get_thread_data() const
std::size_t set_thread_data(std::size_t data)
void rebind(functor_type &&f, thread_id_type id)
void reset_tss()
void reset()
stackless_coroutine::result_type operator()(arg_type arg = arg_type())
operator bool() const
bool is_ready() const
std::ptrdiff_t get_available_stack_space()
std::size_t &get_continuation_recursion_count()

Protected Attributes

functor_type f_
context_state state_
thread_id_type id_
std::size_t thread_data_
std::size_t continuation_recursion_count_

Private Types

enum context_state

Values:

ctx_running
ctx_ready
ctx_exited

Private Functions

bool running() const
bool exited() const

Private Members

HPX_STATIC_CONSTEXPR std::ptrdiff_t hpx::threads::coroutines::stackless_coroutine::default_stack_size = -1

Friends

friend hpx::threads::coroutines::reset_on_exit
struct reset_on_exit

Public Functions

reset_on_exit(stackless_coroutine &this__)
~reset_on_exit()

Public Members

stackless_coroutine &this_

#include <hpx/coroutines/coroutine_fwd.hpp>

#include <hpx/coroutines/thread_id_type.hpp>

namespace hpx
namespace threads

Variables

constexpr thread_id invalid_thread_id
struct thread_id

Public Functions

constexpr thread_id()
constexpr thread_id(thread_id_repr thrd)
thread_id(thread_id const&)
thread_id &operator=(thread_id const&)
thread_id(thread_id &&rhs)
thread_id &operator=(thread_id &&rhs)
constexpr operator bool() const
constexpr thread_id_repr get() const
constexpr void reset()

Private Types

using thread_id_repr = void *

Private Members

thread_id_repr thrd_

Friends

constexpr bool operator==(std::nullptr_t, thread_id const &rhs)
constexpr bool operator!=(std::nullptr_t, thread_id const &rhs)
constexpr bool operator==(thread_id const &lhs, std::nullptr_t)
constexpr bool operator!=(thread_id const &lhs, std::nullptr_t)
constexpr bool operator==(thread_id const &lhs, thread_id const &rhs)
constexpr bool operator!=(thread_id const &lhs, thread_id const &rhs)
constexpr bool operator<(thread_id const &lhs, thread_id const &rhs)
constexpr bool operator>(thread_id const &lhs, thread_id const &rhs)
constexpr bool operator<=(thread_id const &lhs, thread_id const &rhs)
constexpr bool operator>=(thread_id const &lhs, thread_id const &rhs)
template<typename Char, typename Traits>
std::basic_ostream<Char, Traits> &operator<<(std::basic_ostream<Char, Traits> &os, thread_id const &id)

#include <compatibility/hpx/runtime/threads/thread_enums.hpp>

#include <compatibility/hpx/runtime/threads/thread_id_type.hpp>

#include <compatibility/hpx/runtime/threads/coroutines/coroutine.hpp>

#include <compatibility/hpx/runtime/threads/coroutines/coroutine_fwd.hpp>