Iros
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1#pragma once
2
4#include "dius/error.h"
6#include "dius/runtime/tls.h"
7
8#ifndef DIUS_USE_RUNTIME
9#include "dius/posix/thread.h"
10#else
11namespace dius {
12struct PlatformThread;
14
15struct PlatformThread : di::SelfPointer<PlatformThread> {
17 static auto current() -> PlatformThread&;
18
19 PlatformThread() = default;
20
21 auto id() const -> int { return thread_id; }
22 auto join() -> di::Result<void>;
23
24 auto thread_local_storage(usize tls_size) -> di::Span<byte> {
25 return { reinterpret_cast<byte*>(this) - tls_size, tls_size };
26 }
27
28 int thread_id { 0 };
29 di::Function<void()> entry;
30 MemoryRegion stack;
31};
32
34 void operator()(PlatformThread*) const;
35};
36
38}
39#endif
size_t usize
Definition integers.h:33
Expected< T, Error > Result
Definition result.h:8
Definition directory_entry.h:11
auto spawn_thread(PlatformThread &platform_thread) -> di::Result< void >
Definition thread.cpp:29
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