thread_spawn


Description:


[ Version ( since = "1.0" ) ]
public Future thread_spawn (string? thread_name, owned ThreadFunc thread_func)

Spawns a new thread named thread_name running thread_func with user_data passed to it.

thread_func must return a [class@Dex.Future].

If this function is called from a thread that is not running a [class@Dex.Scheduler] then the default scheduler will be used to call user_data_destroy.

If the resulting [class@Dex.Future] has not resolved or rejected, then the same scheduler used to call user_data_destroy will be used to propagate the result to the caller.

Parameters:

thread_name

the name for the thread

thread_func

the function to call on a thread

user_data

closure data for thread_func

user_data_destroy

callback to free user_data which will be called on the same thread calling this function.

Returns:

a [class@Dex.Future] that resolves or rejects the value or error returned from thread_func as a [class@Dex.Future].


Namespace: Dex
Package: libdex-1