標準ライブラリヘッダー <threads.h> (C11)
From cppreference.com
このヘッダーは 並行処理サポートライブラリ の一部であり、スレッド、相互排他、条件変数、スレッドローカルストレージのサポートを提供します。
目次 |
[編集] スレッド
thrd_t
|
スレッドを識別する実装定義の完全オブジェクト型 |
| (C11) |
スレッドを作成する (関数) |
| (C11) |
2つの識別子が同じスレッドを参照しているか確認する (関数) |
| (C11) |
現在のスレッド識別子を取得する (関数) |
| (C11) |
呼び出しスレッドの実行を、与えられた期間だけ一時停止する (関数) |
| (C11) |
現在のタイムスライスを譲る (関数) |
| (C11) |
呼び出しスレッドを終了する (関数) |
| (C11) |
スレッドをデタッチする (関数) |
| (C11) |
スレッドが終了するまでブロックする (関数) |
| スレッドのエラーステータスを示す (定数) | |
| thrd_start_t (C11) |
int(*)(void*) の関数ポインタ型の typedef で、thrd_create によって使用される (typedef) |
[編集] 相互排他
mtx_t
|
ミューテックス識別子 |
| (C11) |
ミューテックスを作成する (関数) |
| (C11) |
ミューテックスがロックされるまでブロックする (関数) |
| (C11) |
ミューテックスがロックされるか、タイムアウトするまでブロックする (関数) |
| (C11) |
ミューテックスをロックするか、既にロックされている場合はブロックせずに戻る (関数) |
| (C11) |
ミューテックスのロックを解除する (関数) |
| (C11) |
ミューテックスを破棄する (関数) |
| (C11)(C11)(C11) |
ミューテックスの型を定義する (enum) |
Call once | |
| (C11) |
関数を一度だけ呼び出す (関数) |
[編集] 条件変数
cnd_t
|
条件変数識別子 |
| (C11) |
条件変数を作成する (関数) |
| (C11) |
条件変数でブロックされている1つのスレッドのブロックを解除する (関数) |
| (C11) |
条件変数でブロックされているすべてのスレッドのブロックを解除する (関数) |
| (C11) |
条件変数でブロックする (関数) |
| (C11) |
タイムアウト付きで条件変数でブロックする (関数) |
| (C11) |
条件変数を破棄する (関数) |
[編集] スレッドローカルストレージ
| (C11)(C23で削除) |
ストレージクラス指定子 _Thread_local のための便利なマクロ (キーワードマクロ) |
tss_t
|
スレッド固有ストレージポインタ |
| (C11) |
デストラクタが呼び出される最大回数 (マクロ定数) |
tss_dtor_t(C11) |
TSSデストラクタに使用される関数ポインタ型 void(*)(void*) (typedef) |
| (C11) |
指定されたデストラクタを持つスレッド固有ストレージポインタを作成する (関数) |
| (C11) |
スレッド固有ストレージから読み込む (関数) |
| (C11) |
スレッド固有ストレージに書き込む (関数) |
| (C11) |
指定されたスレッド固有ポインタが保持するリソースを解放する (関数) |
[編集] 概要
#define __STDC_NO_THREADS__ 202311L #define ONCE_FLAG_INIT /* see description */ #define TSS_DTOR_ITERATIONS /* see description */ typedef /* see description */ cnd_t; typedef /* see description */ thrd_t; typedef /* see description */ tss_t; typedef /* see description */ mtx_t; typedef /* see description */ tss_dtor_t; typedef /* see description */ thrd_start_t; #define mtx_plain /* see description */ #define mtx_recursive /* see description */ #define mtx_timed /* see description */ #define once_flag /* see description */ #define thrd_busy /* see description */ #define thrd_error /* see description */ #define thrd_nomem /* see description */ #define thrd_success /* see description */ #define thrd_timedout /* see description */ void call_once(once_flag* flag, void (*func)(void)); int cnd_broadcast(cnd_t* cond); void cnd_destroy(cnd_t* cond); int cnd_init(cnd_t* cond); int cnd_signal(cnd_t* cond); int cnd_timedwait(cnd_t* restrict cond, mtx_t* restrict mtx, const struct timespec* restrict ts); int cnd_wait(cnd_t* cond, mtx_t* mtx); void mtx_destroy(mtx_t* mtx); int mtx_init(mtx_t* mtx, int type); int mtx_lock(mtx_t* mtx); int mtx_timedlock(mtx_t* restrict mtx, const struct timespec* restrict ts); int mtx_trylock(mtx_t* mtx); int mtx_unlock(mtx_t* mtx); int thrd_create(thrd_t* thr, thrd_start_t func, void* arg); thrd_t thrd_current(void); int thrd_detach(thrd_t thr); int thrd_equal(thrd_t thr0, thrd_t thr1); [[noreturn]] void thrd_exit(int res); int thrd_join(thrd_t thr, int* res); int thrd_sleep(const struct timespec* duration, struct timespec* remaining); void thrd_yield(void); int tss_create(tss_t* key, tss_dtor_t dtor); void tss_delete(tss_t key); void* tss_get(tss_t key); int tss_set(tss_t key, void* val);