Iros
 
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/sync/prelude.h"
5#include "di/util/prelude.h"
7#include "dius/error.h"
8#include "dius/runtime/tls.h"
9
10namespace dius {
11struct PlatformThread;
13
14struct PlatformThread : di::SelfPointer<PlatformThread> {
16 static auto current() -> PlatformThread&;
17
18 PlatformThread() = default;
19
20 auto id() const -> int { return thread_id; }
21 auto join() -> di::Result<void>;
22
24 return { reinterpret_cast<byte*>(this) - tls_size, tls_size };
25 }
26
27 int thread_id { 0 };
29 byte* stack { nullptr };
31};
32
34 void operator()(PlatformThread*) const;
35};
36}
Definition function.h:365
Definition atomic.h:15
Definition span_forward_declaration.h:10
size_t usize
Definition integers.h:33
Expected< T, Error > Result
Definition result.h:8
Definition directory_entry.h:11
Definition thread.h:33
void operator()(PlatformThread *) const
Definition thread.cpp:33
Definition thread.h:10
static auto current() -> PlatformThread &
Definition thread.cpp:22
auto thread_local_storage(usize tls_size) -> di::Span< byte >
Definition thread.h:23
static auto create(runtime::TlsInfo) -> di::Result< di::Box< PlatformThread, PlatformThreadDeleter > >
Definition thread.cpp:15
PlatformThread()=default
di::Function< void()> entry
Definition thread.h:30
auto join() -> di::Result< void >
Definition thread.cpp:44
int thread_id
Definition thread.h:27
auto id() const -> int
Definition thread.h:20
byte * stack
Definition thread.h:29
di::Atomic< int > join_word
Definition thread.h:28