ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
windows.hpp File Reference

Windows and MinGW native thread-control implementation fragment. More...

Go to the source code of this file.

Classes

class  hresult_error_category
 
struct  thread_description_api
 
struct  local_free_deleter
 

Typedefs

using set_thread_description_fn = HRESULT(WINAPI *)(HANDLE, PCWSTR)
 
using get_thread_description_fn = HRESULT(WINAPI *)(HANDLE, PWSTR *)
 
using module_lookup_fn = HMODULE(WINAPI *)(LPCWSTR)
 
using proc_lookup_fn = FARPROC(WINAPI *)(HMODULE, LPCSTR)
 

Functions

auto last_win32_error () -> std::error_code
 
auto apply_priority (HANDLE handle, native_thread_priority priority) -> expected< void, std::error_code >
 
auto apply_windows_thread_priority (HANDLE handle, int priority) -> expected< void, std::error_code >
 
auto apply_nice_value (HANDLE handle, int nice_value) -> expected< void, std::error_code >
 
auto apply_scheduling_policy (HANDLE handle, native_scheduling_policy policy, native_thread_priority priority) -> expected< void, std::error_code >
 
auto apply_affinity (HANDLE handle, native_thread_affinity const &affinity) -> expected< void, std::error_code >
 
auto hresult_category () -> std::error_category const &
 
auto error_from_hresult (HRESULT result) -> std::error_code
 
auto resolve_thread_description_api (module_lookup_fn module_lookup=GetModuleHandleW, proc_lookup_fn proc_lookup=GetProcAddress) -> thread_description_api
 
auto resolved_set_thread_description () -> expected< set_thread_description_fn, std::error_code >
 
auto resolved_get_thread_description () -> expected< get_thread_description_fn, std::error_code >
 
auto utf8_to_utf16 (std::string const &value) -> expected< std::wstring, std::error_code >
 
auto utf16_to_utf8 (PCWSTR value) -> expected< std::string, std::error_code >
 
auto apply_name (HANDLE handle, std::string const &name) -> expected< void, std::error_code >
 
auto read_name (HANDLE handle) -> expected< std::string, std::error_code >
 
auto read_affinity (HANDLE handle) -> expected< native_thread_affinity, std::error_code >
 
auto read_priority (HANDLE handle) -> std::optional< int >
 
auto read_nice_value (HANDLE handle) -> expected< int, std::error_code >
 
auto read_scheduling_policy (HANDLE handle) -> std::optional< native_scheduling_policy >
 
auto apply_priority (native_thread_id tid, native_thread_priority priority) -> expected< void, std::error_code >
 
auto apply_windows_thread_priority (native_thread_id tid, int priority) -> expected< void, std::error_code >
 
auto apply_nice_value (native_thread_id tid, int nice_value) -> expected< void, std::error_code >
 
auto apply_scheduling_policy (native_thread_id tid, native_scheduling_policy policy, native_thread_priority priority) -> expected< void, std::error_code >
 
auto apply_affinity (native_thread_id tid, native_thread_affinity const &affinity) -> expected< void, std::error_code >
 
auto apply_name (native_thread_id tid, std::string const &name) -> expected< void, std::error_code >
 
auto read_name (native_thread_id tid) -> expected< std::string, std::error_code >
 
auto read_affinity (native_thread_id tid) -> expected< native_thread_affinity, std::error_code >
 
auto read_priority (native_thread_id tid) -> std::optional< int >
 
auto read_nice_value (native_thread_id tid) -> expected< int, std::error_code >
 
auto read_scheduling_policy (native_thread_id tid) -> std::optional< native_scheduling_policy >
 

Detailed Description

Windows and MinGW native thread-control implementation fragment.

Included by native.hpp inside threadschedule::detail after the shared native scheduling value types have been declared.

Definition in file windows.hpp.

Typedef Documentation

◆ get_thread_description_fn

using get_thread_description_fn = HRESULT(WINAPI*)(HANDLE, PWSTR*)

Definition at line 87 of file windows.hpp.

◆ module_lookup_fn

using module_lookup_fn = HMODULE(WINAPI*)(LPCWSTR)

Definition at line 136 of file windows.hpp.

◆ proc_lookup_fn

using proc_lookup_fn = FARPROC(WINAPI*)(HMODULE, LPCSTR)

Definition at line 137 of file windows.hpp.

◆ set_thread_description_fn

using set_thread_description_fn = HRESULT(WINAPI*)(HANDLE, PCWSTR)

Definition at line 86 of file windows.hpp.

Function Documentation

◆ apply_affinity() [1/2]

auto apply_affinity ( HANDLE  handle,
native_thread_affinity const &  affinity 
) -> expected<void, std::error_code>
inline

Definition at line 56 of file windows.hpp.

References last_win32_error().

Referenced by apply_affinity().

◆ apply_affinity() [2/2]

auto apply_affinity ( native_thread_id  tid,
native_thread_affinity const &  affinity 
) -> expected<void, std::error_code>
inline

Definition at line 390 of file windows.hpp.

References apply_affinity(), and last_win32_error().

◆ apply_name() [1/2]

auto apply_name ( HANDLE  handle,
std::string const &  name 
) -> expected<void, std::error_code>
inline

Definition at line 250 of file windows.hpp.

References error_from_hresult(), resolved_set_thread_description(), and utf8_to_utf16().

Referenced by apply_name().

◆ apply_name() [2/2]

auto apply_name ( native_thread_id  tid,
std::string const &  name 
) -> expected<void, std::error_code>
inline

Definition at line 400 of file windows.hpp.

References apply_name().

◆ apply_nice_value() [1/2]

auto apply_nice_value ( HANDLE  handle,
int  nice_value 
) -> expected<void, std::error_code>
inline

Definition at line 34 of file windows.hpp.

References apply_priority().

Referenced by apply_nice_value().

◆ apply_nice_value() [2/2]

auto apply_nice_value ( native_thread_id  tid,
int  nice_value 
) -> expected<void, std::error_code>
inline

Definition at line 370 of file windows.hpp.

References apply_nice_value(), and last_win32_error().

◆ apply_priority() [1/2]

auto apply_priority ( HANDLE  handle,
native_thread_priority  priority 
) -> expected<void, std::error_code>
inline

Definition at line 14 of file windows.hpp.

Referenced by apply_nice_value(), and apply_priority().

◆ apply_priority() [2/2]

auto apply_priority ( native_thread_id  tid,
native_thread_priority  priority 
) -> expected<void, std::error_code>
inline

Definition at line 351 of file windows.hpp.

References apply_priority(), and last_win32_error().

◆ apply_scheduling_policy() [1/2]

auto apply_scheduling_policy ( HANDLE  handle,
native_scheduling_policy  policy,
native_thread_priority  priority 
) -> expected<void, std::error_code>
inline

Definition at line 42 of file windows.hpp.

Referenced by apply_scheduling_policy().

◆ apply_scheduling_policy() [2/2]

auto apply_scheduling_policy ( native_thread_id  tid,
native_scheduling_policy  policy,
native_thread_priority  priority 
) -> expected<void, std::error_code>
inline

Definition at line 379 of file windows.hpp.

References apply_scheduling_policy(), and last_win32_error().

◆ apply_windows_thread_priority() [1/2]

auto apply_windows_thread_priority ( HANDLE  handle,
int  priority 
) -> expected<void, std::error_code>
inline

◆ apply_windows_thread_priority() [2/2]

auto apply_windows_thread_priority ( native_thread_id  tid,
int  priority 
) -> expected<void, std::error_code>
inline

Definition at line 361 of file windows.hpp.

References apply_windows_thread_priority(), and last_win32_error().

◆ error_from_hresult()

auto error_from_hresult ( HRESULT  result) -> std::error_code
inline

Definition at line 115 of file windows.hpp.

References hresult_category().

Referenced by apply_name(), and read_name().

◆ hresult_category()

auto hresult_category ( ) -> std::error_category const&
inline

Definition at line 108 of file windows.hpp.

Referenced by error_from_hresult().

◆ last_win32_error()

◆ read_affinity() [1/2]

auto read_affinity ( HANDLE  handle) -> expected<native_thread_affinity, std::error_code>
inline

Definition at line 285 of file windows.hpp.

References last_win32_error().

Referenced by read_affinity().

◆ read_affinity() [2/2]

auto read_affinity ( native_thread_id  tid) -> expected<native_thread_affinity, std::error_code>
inline

Definition at line 420 of file windows.hpp.

References last_win32_error(), and read_affinity().

◆ read_name() [1/2]

auto read_name ( HANDLE  handle) -> expected<std::string, std::error_code>
inline

Definition at line 267 of file windows.hpp.

References error_from_hresult(), resolved_get_thread_description(), and utf16_to_utf8().

Referenced by read_name().

◆ read_name() [2/2]

auto read_name ( native_thread_id  tid) -> expected<std::string, std::error_code>
inline

Definition at line 410 of file windows.hpp.

References last_win32_error(), and read_name().

◆ read_nice_value() [1/2]

auto read_nice_value ( HANDLE  handle) -> expected<int, std::error_code>
inline

Definition at line 322 of file windows.hpp.

References last_win32_error().

Referenced by read_nice_value().

◆ read_nice_value() [2/2]

auto read_nice_value ( native_thread_id  tid) -> expected<int, std::error_code>
inline

Definition at line 440 of file windows.hpp.

References last_win32_error(), and read_nice_value().

◆ read_priority() [1/2]

auto read_priority ( HANDLE  handle) -> std::optional<int>
inline

Definition at line 311 of file windows.hpp.

Referenced by read_priority().

◆ read_priority() [2/2]

auto read_priority ( native_thread_id  tid) -> std::optional<int>
inline

Definition at line 430 of file windows.hpp.

References read_priority().

◆ read_scheduling_policy() [1/2]

auto read_scheduling_policy ( HANDLE  handle) -> std::optional<native_scheduling_policy>
inline

Definition at line 343 of file windows.hpp.

Referenced by read_scheduling_policy().

◆ read_scheduling_policy() [2/2]

auto read_scheduling_policy ( native_thread_id  tid) -> std::optional<native_scheduling_policy>
inline

Definition at line 449 of file windows.hpp.

References read_scheduling_policy().

◆ resolve_thread_description_api()

auto resolve_thread_description_api ( module_lookup_fn  module_lookup = GetModuleHandleW,
proc_lookup_fn  proc_lookup = GetProcAddress 
) -> thread_description_api
inline

◆ resolved_get_thread_description()

auto resolved_get_thread_description ( ) -> expected<get_thread_description_fn, std::error_code>
inline

Definition at line 190 of file windows.hpp.

References resolve_thread_description_api().

Referenced by read_name().

◆ resolved_set_thread_description()

auto resolved_set_thread_description ( ) -> expected<set_thread_description_fn, std::error_code>
inline

Definition at line 172 of file windows.hpp.

References resolve_thread_description_api().

Referenced by apply_name().

◆ utf16_to_utf8()

auto utf16_to_utf8 ( PCWSTR  value) -> expected<std::string, std::error_code>
inline

Definition at line 236 of file windows.hpp.

References last_win32_error().

Referenced by read_name().

◆ utf8_to_utf16()

auto utf8_to_utf16 ( std::string const &  value) -> expected<std::wstring, std::error_code>
inline

Definition at line 208 of file windows.hpp.

References last_win32_error().

Referenced by apply_name().