cheatah
Class

thread::Thread

The owning handle to one spawned thread — obtained from thread.spawn, never constructed directly by a cheatah program.

Move-only (there is exactly one owner of a thread), and the destructor JOINS: dropping the handle — normally, via with, or during unwinding — always waits for the worker to finish, on every exit path. There is no detach.

If the worker threw and join() never surfaced it, the destructor reports one line on stderr (cheatah thread: unhandled exception in thread: ...) — the honest fallback, since a destructor must not throw.

Concurrency

the handle itself is not internally synchronized — drive a given Thread from one thread at a time (the worker it owns is, of course, another thread; join() is the synchronization point with it).

System testStdlibE2E.Thread

Functions

fn Thread · 3 overloads
Thread(std::thread t, std::shared_ptr< detail::State > state) noexceptsource#
Thread(Thread &&other) noexceptsource#
Thread(const Thread &)=deletesource#

The grant path used by spawn: adopt a running thread and its shared error slot.

Public but not part of the cheatah surface (no module factory returns the pieces), matching the memory module's no-friend stance.

Parameters
t

the running thread to own.

state

the error slot the spawn trampoline writes into.

Complexity

O(1).

Allocation

none (moves the handles in).

Concurrency

the worker is already running when the handle adopts it.

fn operator= · 2 overloads
Thread & operator=(Thread &&other) noexceptsource#
Thread & operator=(const Thread &)=deletesource#

Move-assign: the destination first settles its own thread (join + report an unobserved error), then adopts the source's.

Parameters
other

the handle to take the thread from (left non-joinable).

Returns

this handle, now owning other's thread.

Complexity

O(join).

Allocation

none.

Concurrency

may block: the destination joins its old worker before adopting the new one.

fn ~Thread() source#

Joins if still joinable; reports an unobserved worker exception on stderr (one line).

Complexity

O(join) — blocks until the worker finishes.

Allocation

none.

Concurrency

blocks the destroying thread until the worker finishes — on every exit path, including unwinding.

fn void join() source#

Block until the worker finishes.

If the worker escaped with an exception, RE-THROW it here — catch it with try { t.join() } catch e { ... }. Joining a thread that was already joined (or moved away) raises.

Complexity

O(join) — blocks until the worker finishes.

Allocation

none.

Concurrency

blocks the calling thread; the worker's writes happen-before join() returns (the join is the synchronization). One-shot — a second join raises.

System testStdlibE2E.Thread
fn bool joinable() const noexcept source#

Does this handle still own a running/unjoined thread?

Returns

true until join() (or a move-away); false after.

Complexity

O(1).

Allocation

none.

fn void settle() noexcept source#

Constants & variables

var std::thread t_ source#
var std::shared_ptr< detail::State > state_ source#