hpx/threading_base/thread_data.hpp¶
See Public API for a list of names and headers that are part of the public HPX API.
-
namespace
hpx
-
namespace
threads
Functions
-
thread_data *
get_self_id_data
()¶ The function get_self_id_data returns the data of the HPX thread id associated with the current thread (or nullptr if the current thread is not a HPX thread).
-
thread_data *
get_thread_id_data
(thread_id_ref_type const &tid)¶
-
thread_data *
get_thread_id_data
(thread_id_type const &tid)¶
-
thread_self &
get_self
()¶ The function get_self returns a reference to the (OS thread specific) self reference to the current HPX thread.
-
thread_self *
get_self_ptr
() The function get_self_ptr returns a pointer to the (OS thread specific) self reference to the current HPX thread.
-
thread_self_impl_type *
get_ctx_ptr
()¶ The function get_ctx_ptr returns a pointer to the internal data associated with each coroutine.
-
thread_self *
get_self_ptr_checked
(error_code &ec = throws)¶ The function get_self_ptr_checked returns a pointer to the (OS thread specific) self reference to the current HPX thread.
-
thread_id_type
get_self_id
() The function get_self_id returns the HPX thread id of the current thread (or zero if the current thread is not a HPX thread).
-
thread_id_type
get_parent_id
()¶ The function get_parent_id returns the HPX thread id of the current thread’s parent (or zero if the current thread is not a HPX thread).
- Note
This function will return a meaningful value only if the code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE being defined.
-
std::size_t
get_parent_phase
()¶ The function get_parent_phase returns the HPX phase of the current thread’s parent (or zero if the current thread is not a HPX thread).
- Note
This function will return a meaningful value only if the code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE being defined.
-
std::ptrdiff_t
get_self_stacksize
()¶ The function get_self_stacksize returns the stack size of the current thread (or zero if the current thread is not a HPX thread).
-
thread_stacksize
get_self_stacksize_enum
()¶ The function get_self_stacksize_enum returns the stack size of the /.
-
std::uint32_t
get_parent_locality_id
()¶ The function get_parent_locality_id returns the id of the locality of the current thread’s parent (or zero if the current thread is not a HPX thread).
- Note
This function will return a meaningful value only if the code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE being defined.
-
class
thread_data
: public thread_data_reference_counting¶ - #include <thread_data.hpp>
A thread is the representation of a ParalleX thread. It’s a first class object in ParalleX. In our implementation this is a user level thread running on top of one of the OS threads spawned by the thread-manager.
A thread encapsulates:
A thread status word (see the functions thread::get_state and thread::set_state)
A function to execute (the thread function)
A frame (in this implementation this is a block of memory used as the threads stack)
A block of registers (not implemented yet)
Generally, threads are not created or executed directly. All functionality related to the management of threads is implemented by the thread-manager.
Subclassed by hpx::threads::thread_data_stackful, hpx::threads::thread_data_stackless
Public Types
-
using
spinlock_pool
= util::spinlock_pool<thread_data>¶
Public Functions
-
thread_data
(thread_data const&)¶
-
thread_data
(thread_data&&)¶
-
thread_data &
operator=
(thread_data const&)¶
-
thread_data &
operator=
(thread_data&&)¶
-
thread_state
get_state
(std::memory_order order = std::memory_order_acquire) const¶ The get_state function queries the state of this thread instance.
- Return
This function returns the current state of this thread. It will return one of the values as defined by the thread_state enumeration.
- Note
This function will be seldom used directly. Most of the time the state of a thread will be retrieved by using the function threadmanager::get_state.
-
thread_state
set_state
(thread_schedule_state state, thread_restart_state state_ex = thread_restart_state::unknown, std::memory_order load_order = std::memory_order_acquire, std::memory_order exchange_order = std::memory_order_seq_cst)¶ The set_state function changes the state of this thread instance.
- Note
This function will be seldom used directly. Most of the time the state of a thread will have to be changed using the threadmanager. Moreover, changing the thread state using this function does not change its scheduling status. It only sets the thread’s status word. To change the thread’s scheduling status threadmanager::set_state should be used.
- Parameters
newstate
: [in] The new state to be set for the thread.
-
bool
set_state_tagged
(thread_schedule_state newstate, thread_state &prev_state, thread_state &new_tagged_state, std::memory_order exchange_order = std::memory_order_seq_cst)¶
-
bool
restore_state
(thread_state new_state, thread_state old_state, std::memory_order load_order = std::memory_order_relaxed, std::memory_order load_exchange = std::memory_order_seq_cst)¶ The restore_state function changes the state of this thread instance depending on its current state. It will change the state atomically only if the current state is still the same as passed as the second parameter. Otherwise it won’t touch the thread state of this instance.
- Note
This function will be seldom used directly. Most of the time the state of a thread will have to be changed using the threadmanager. Moreover, changing the thread state using this function does not change its scheduling status. It only sets the thread’s status word. To change the thread’s scheduling status threadmanager::set_state should be used.
- Return
This function returns true if the state has been changed successfully
- Parameters
newstate
: [in] The new state to be set for the thread.oldstate
: [in] The old state of the thread which still has to be the current state.
-
bool
restore_state
(thread_schedule_state new_state, thread_restart_state state_ex, thread_state old_state, std::memory_order load_exchange = std::memory_order_seq_cst)¶
-
constexpr std::uint64_t
get_component_id
() const¶ Return the id of the component this thread is running in.
-
util::thread_description
get_description
() const¶
-
util::thread_description
set_description
(util::thread_description)¶
-
util::thread_description
get_lco_description
() const¶
-
util::thread_description
set_lco_description
(util::thread_description)¶
-
constexpr thread_id_type
get_parent_thread_id
() const¶ Return the thread id of the parent thread.
-
constexpr thread_priority
get_priority
() const¶
-
void
set_priority
(thread_priority priority)¶
-
bool
interruption_requested
() const¶
-
bool
interruption_enabled
() const¶
-
bool
set_interruption_enabled
(bool enable)¶
-
void
interrupt
(bool flag = true)¶
-
bool
interruption_point
(bool throw_on_interrupt = true)¶
-
bool
add_thread_exit_callback
(function<void()> const &f)¶
-
void
run_thread_exit_callbacks
()¶
-
void
free_thread_exit_callbacks
()¶
-
bool
is_stackless
() const¶
-
void
destroy_thread
()¶
-
policies::scheduler_base *
get_scheduler_base
() const¶
-
thread_stacksize
get_stack_size_enum
() const¶
-
template<typename
ThreadQueue
>
ThreadQueue &get_queue
()¶
-
coroutine_type::result_type
operator()
(hpx::execution_base::this_thread::detail::agent_storage *agent_storage)¶ Execute the thread function.
- Return
This function returns the thread state the thread should be scheduled from this point on. The thread manager will use the returned value to set the thread’s scheduling status.
-
virtual thread_id_type
get_thread_id
() const¶
-
virtual void
init
() = 0¶
-
virtual void
rebind
(thread_init_data &init_data) = 0¶
-
thread_data
(thread_init_data &init_data, void *queue, std::ptrdiff_t stacksize, bool is_stackless = false, thread_id_addref addref = thread_id_addref::yes)¶
-
virtual
~thread_data
()¶
-
virtual void
destroy
() = 0¶
Protected Functions
-
thread_restart_state
set_state_ex
(thread_restart_state new_state)¶ The set_state function changes the extended state of this thread instance.
- Note
This function will be seldom used directly. Most of the time the state of a thread will have to be changed using the threadmanager.
- Parameters
newstate
: [in] The new extended state to be set for the thread.
-
void
rebind_base
(thread_init_data &init_data)¶
Private Members
-
thread_priority
priority_
¶
-
bool
requested_interrupt_
¶
-
bool
enabled_interrupt_
¶
-
bool
ran_exit_funcs_
¶
-
const bool
is_stackless_
¶
-
policies::scheduler_base *
scheduler_base_
¶
-
thread_stacksize
stacksize_enum_
¶
-
void *
queue_
¶
-
thread_data *
-
namespace