Skip to content

Thread

Spice
import "std/os/thread";

Thread struct

Lightweight thread, that uses posix threads (pthread) under the hood.

Constructors

ctor

Spice
public p Thread.ctor(p() threadRoutine)

Construct a thread from a procedure to run

Parameters

Name Type Description
threadRoutine p() Procedure to execute on the thread

ctor

Spice
public p Thread.ctor(const Lambda<p()>& threadRoutine)

Construct a thread from a lambda to run

Parameters

Name Type Description
threadRoutine const Lambda<p()>& Lambda to execute on the thread

Methods

run

Spice
public p Thread.run()

Start the thread

join

Spice
public p Thread.join()

Wait synchronous until the thread has terminated

getId

Spice
public f<Pthread_t> Thread.getId()

Retrieve the ID of the current thread

Returns: Pthread_t

Functions

getThreadId

Spice
public f<Pthread_t> getThreadId()

Retrieve the ID of the current thread

Returns: Pthread_t