Creates and controls an automatically rejoins on destruction thread, sets its priority, and gets its status.
Creates and controls an automatically rejoins on destruction thread, sets its priority,...
Definition jthread.h:31
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.h:43
#define core_export_
Define shared library export.
Definition core_export.h:13
- Inheritance
- xtd::object → xtd::threading::jthread
- Header
#include <xtd/threading/jthread>
- Namespace
- xtd::threading
- Library
- xtd.core
- Examples
- The following example shows how to use xtd::threading::jthread.
#include <xtd/threading/jthread>
#include <xtd/block_scope>
#include <xtd/console>
auto main() -> int {
auto thread_proc = [] {
};
}
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static jthread start_new(const xtd::threading::thread_start &start)
Create and immedialtely start a xtd::threading::jthread with specified method.
static thread & current_thread() noexcept
Gets the currently running thread.
static void sleep(int32 milliseconds_timeout)
Suspends the current thread for a specified time.
string name() const noexcept
Gets the name of the thread.
#define block_scope_(...)
The specified expression is cleared automatically when the scope is ended.
Definition block_scope.h:25
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
|
static const intptr | invalid_handle |
| Represents an invalid native operating system handle. This field is read-only.
|
|
static const intptr | invalid_thread_id |
| Represents an invalid native operating system thread id. This field is read-only.
|
|
| thread (const xtd::threading::parameterized_thread_start &start) |
| Initializes a new instance of the xtd::threading::thread class, specifying a delegate that allows an object to be passed to the thread when the thread is started.
|
|
| thread (const xtd::threading::parameterized_thread_start &start, int32 max_stack_size) |
| Initializes a new instance of the xtd::threading::thread class, specifying a delegate that allows an object to be passed to the thread when the thread is started and specifying the maximum stack size for the thread.
|
|
| thread (const xtd::threading::thread_start &start) |
| Initializes a new instance of the xtd::threading::thread class.
|
|
| thread (const xtd::threading::thread_start &start, int32 max_stack_size) |
| Initializes a new instance of the xtd::threading::thread class, specifying the maximum stack size for the thread.
|
|
bool | auto_join () const noexcept |
| Gets a value indicating the current thread wiil be joined when destroyed.
|
|
thread & | auto_join (bool value) |
| Sets a value indicating the current thread wiil be joined when destroyed.
|
|
intptr | handle () const noexcept |
| Gets the native operating system handle.
|
|
bool | is_alive () const noexcept |
| Gets a value indicating the execution status of the current thread.
|
|
bool | is_background () const noexcept |
| Gets a value indicating whether or not a thread is a background thread.
|
|
thread & | is_background (bool value) |
| Sets a value indicating whether or not a thread is a background thread.
|
|
bool | is_main_thread () const noexcept |
| Gets a value indicating the current thread is the main thread.
|
|
bool | is_thread_pool_thread () const noexcept |
| Gets a value indicating whether or not a thread belongs to the managed thread pool.
|
|
bool | joinable () const noexcept |
| Gets a value indicating the current thread is joinable.
|
|
int32 | managed_thread_id () const noexcept |
| Gets a unique identifier for the current managed thread.
|
|
string | name () const noexcept |
| Gets the name of the thread.
|
|
thread & | name (const string &value) |
| Sets the name of the thread.
|
|
xtd::threading::thread_priority | priority () const noexcept |
| Gets a value indicating the scheduling priority of a thread.
|
|
thread & | priority (xtd::threading::thread_priority value) |
| Sets a value indicating the scheduling priority of a thread.
|
|
intptr | thread_id () const noexcept |
| Gets the native operating system thread id.
|
|
xtd::threading::thread_state | thread_state () const noexcept |
| Gets a value containing the states of the current thread.
|
|
void | abort () |
| Raises a xtd::threading::thread_aborted_exception in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.
|
|
void | detach () |
| Sets the thread background.
|
|
void | interrupt () |
| Interrupts a thread that is in the xtd::threading::thread_state::wait_sleep_join thread state.
|
|
void | join () |
| Blocks the calling thread until this thread object terminates, while continuing to perform standard COM and SendMessage pumping.
|
|
bool | join (int32 milliseconds_timeout) |
| Blocks the calling thread until this thread object terminates or the specified time elapses, while continuing to perform standard COM and SendMessage pumping.
|
|
bool | join (const time_span &timeout) |
| Blocks the calling thread until this thread object terminates or the specified time elapses, while continuing to perform standard COM and SendMessage pumping.
|
|
void | resume () |
| Resumes a thread that has been suspended (Should not be used).
|
|
void | start () |
| Causes the operating system to change the state of the current instance to xtd::threading::thread_state::running.
|
|
void | start (std::any obj) |
| Causes the operating system to change the state of the current instance to xtd::threading::thread_state::running.
|
|
void | suspend () |
| Either suspends the thread, or if the thread is already suspended, has no effect (Should not be used).
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object.
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type.
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance.
|
|
template<typename object_t > |
xtd::uptr< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object.
|
|
virtual xtd::string | to_string () const noexcept |
| Returns a xtd::string that represents the current object.
|
|
static thread & | current_thread () noexcept |
| Gets the currently running thread.
|
|
static thread & | main_thread () |
| Gets the main thread.
|
|
static thread | start_new (const xtd::threading::thread_start &start) |
| Create and immedialtely start a xtd::threading::thread with specified method.
|
|
static thread | start_new (const xtd::threading::parameterized_thread_start &start, std::any obj) |
| Create and immedialtely start a xtd::threading::thread with specified method.
|
|
static void | join_all () |
| Blocks the calling thread until all joinable threads terminate.
|
|
static bool | join_all (int32 milliseconds_timeout) |
| Blocks the calling thread until all joinable threads terminate or the specified time elapses, while continuing.
|
|
static bool | join_all (const time_span &timeout) |
| Blocks the calling thread until all joinable threads terminate or the specified time elapses, while continuing.
|
|
template<typename collection_t > |
static void | join_all (const collection_t &threads) |
| Blocks the calling thread until all specified joinable threads collection terminate.
|
|
template<typename collection_t > |
static bool | join_all (const collection_t &threads, int32 milliseconds_timeout) |
| Blocks the calling thread until all specified joinable threads collection terminate or the specified time elapses, while continuing.
|
|
template<typename collection_t > |
static bool | join_all (const collection_t &threads, const time_span &timeout) |
| Blocks the calling thread until all specified joinable threads collection terminate or the specified time elapses, while continuing.
|
|
static void | sleep (int32 milliseconds_timeout) |
| Suspends the current thread for a specified time.
|
|
static void | sleep (const time_span &timeout) |
| Suspends the current thread for a specified time.
|
|
static void | spin_wait (int32 iterations) |
| Causes a thread to wait the number of times defined by the iterations parameter.
|
|
static bool | yield () |
| Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|