| 1 | module sync |
| 2 | |
| 3 | fn 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 | |
| 13 | pub fn thread_id() u64 { |
| 14 | return u64(C.pthread_self()) |
| 15 | } |
| 16 | |