Creates and controls an automatically rejoins on destruction thread, sets its priority, and gets its status.
jthread(const xtd::threading::parameterized_thread_start &start)
Initializes a new instance of the xtd::threading::jthread class, specifying a delegate that allows an...
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.hpp:49
#define core_export_
Define shared library export.
Definition core_export.hpp: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/xtd>
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 auto start_new(const xtd::threading::thread_start &start) -> jthread
Create and immedialtely start a xtd::threading::jthread with specified method.
static auto sleep(int32 milliseconds_timeout) -> void
Suspends the current thread for a specified time.
static auto current_thread() noexcept -> thread &
Gets the currently running thread.
auto name() const noexcept -> string
Gets the name of the thread.
#define using_(...)
The specified expression is cleared automatically when the scope is ended.
Definition using.hpp:36
|
| 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.
|
| auto | auto_join () const noexcept -> bool |
| | Gets a value indicating the current thread wiil be joined when destroyed.
|
| auto | auto_join (bool value) -> thread & |
| | Sets a value indicating the current thread wiil be joined when destroyed.
|
| auto | handle () const noexcept -> intptr |
| | Gets the native operating system handle.
|
| auto | is_alive () const noexcept -> bool |
| | Gets a value indicating the execution status of the current thread.
|
| auto | is_background () const noexcept -> bool |
| | Gets a value indicating whether or not a thread is a background thread.
|
| auto | is_background (bool value) -> thread & |
| | Sets a value indicating whether or not a thread is a background thread.
|
| auto | is_main_thread () const noexcept -> bool |
| | Gets a value indicating the current thread is the main thread.
|
| auto | is_thread_pool_thread () const noexcept -> bool |
| | Gets a value indicating whether or not a thread belongs to the managed thread pool.
|
| auto | joinable () const noexcept -> bool |
| | Gets a value indicating the current thread is joinable.
|
| auto | managed_thread_id () const noexcept -> int32 |
| | Gets a unique identifier for the current managed thread.
|
| auto | name () const noexcept -> string |
| | Gets the name of the thread.
|
| auto | name (const string &value) -> thread & |
| | Sets the name of the thread.
|
| auto | priority () const noexcept -> xtd::threading::thread_priority |
| | Gets a value indicating the scheduling priority of a thread.
|
| auto | priority (xtd::threading::thread_priority value) -> thread & |
| | Sets a value indicating the scheduling priority of a thread.
|
| auto | processor_affinity () const noexcept -> const xtd::array< xtd::size > & |
| | Gets the processors on which the associated thread can run.
|
| auto | processor_affinity (const xtd::array< xtd::size > &value) -> thread & |
| | Sets the processors on which the associated thread can run.
|
| auto | thread_id () const noexcept -> intptr |
| | Gets the native operating system thread id.
|
| auto | thread_state () const noexcept -> xtd::threading::thread_state |
| | Gets a value containing the states of the current thread.
|
| auto | abort () -> void |
| | 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.
|
| auto | detach () -> void |
| | Sets the thread background.
|
| auto | get_hash_code () const noexcept -> xtd::size override |
| | Serves as a hash function for a particular type.
|
| auto | interrupt () -> void |
| | Interrupts a thread that is in the xtd::threading::thread_state::wait_sleep_join thread state.
|
| auto | join () -> void |
| | Blocks the calling thread until this thread object terminates, while continuing to perform standard COM and SendMessage pumping.
|
| auto | join (int32 milliseconds_timeout) -> bool |
| | Blocks the calling thread until this thread object terminates or the specified time elapses, while continuing to perform standard COM and SendMessage pumping.
|
| auto | join (const time_span &timeout) -> bool |
| | Blocks the calling thread until this thread object terminates or the specified time elapses, while continuing to perform standard COM and SendMessage pumping.
|
| auto | resume () -> void |
| | Resumes a thread that has been suspended (Should not be used).
|
| auto | start () -> void |
| | Causes the operating system to change the state of the current instance to xtd::threading::thread_state::running.
|
| auto | start (const xtd::any_object &obj) -> void |
| | Causes the operating system to change the state of the current instance to xtd::threading::thread_state::running.
|
| auto | suspend () -> void |
| | 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 type_object | get_type () const noexcept |
| | Gets the type of the current instance.
|
| template<class object_t> |
| xtd::unique_ptr_object< object_t > | memberwise_clone () const |
| | Creates a shallow copy of the current object.
|
| virtual xtd::string | to_string () const |
| | Returns a xtd::string that represents the current object.
|
| static auto | current_thread () noexcept -> thread & |
| | Gets the currently running thread.
|
| static auto | main_thread () -> thread & |
| | Gets the main thread.
|
| static auto | start_new (const xtd::threading::thread_start &start) -> thread |
| | Create and immedialtely start a xtd::threading::thread with specified method.
|
| static auto | start_new (const xtd::threading::parameterized_thread_start &start, const xtd::any_object &obj) -> thread |
| | Create and immedialtely start a xtd::threading::thread with specified method.
|
| static auto | join_all () -> void |
| | Blocks the calling thread until all joinable threads terminate.
|
| static auto | join_all (int32 milliseconds_timeout) -> bool |
| | Blocks the calling thread until all joinable threads terminate or the specified time elapses, while continuing.
|
| static auto | join_all (const time_span &timeout) -> bool |
| | Blocks the calling thread until all joinable threads terminate or the specified time elapses, while continuing.
|
| template<class collection_t> |
| static auto | join_all (const collection_t &threads) -> void |
| | Blocks the calling thread until all specified joinable threads collection terminate.
|
| template<class collection_t> |
| static auto | join_all (const collection_t &threads, int32 milliseconds_timeout) -> bool |
| | Blocks the calling thread until all specified joinable threads collection terminate or the specified time elapses, while continuing.
|
| template<class collection_t> |
| static auto | join_all (const collection_t &threads, const time_span &timeout) -> bool |
| | Blocks the calling thread until all specified joinable threads collection terminate or the specified time elapses, while continuing.
|
| static auto | sleep (int32 milliseconds_timeout) -> void |
| | Suspends the current thread for a specified time.
|
| static auto | sleep (const time_span &timeout) -> void |
| | Suspends the current thread for a specified time.
|
| static auto | spin_wait (int32 iterations) -> void |
| | Causes a thread to wait the number of times defined by the iterations parameter.
|
| static auto | yield () noexcept -> bool |
| | 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<class object_a_t, class 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<class object_a_t, class 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.
|