v / vlib / sync / thread_default.c.v
15 lines · 12 sloc · 600 bytes · 5b668dba2b627357164b7e0e6fa1d9de61513fc6
Raw
1module sync
2
3fn C.pthread_self() usize
4
5// thread_id returns a unique identifier for the caller thread.
6// All *currently* running threads in the same process, will have *different* thread identifiers.
7// Note: if a thread finishes, and another starts, the identifier of the old thread may be
8// reused for the newly started thread.
9// In other words, thread IDs are guaranteed to be unique only within a process.
10// A thread ID may be reused after a terminated thread has been joined (with `t.wait()`),
11// or when the thread has terminated.
12
13pub fn thread_id() u64 {
14 return u64(C.pthread_self())
15}
16