Dex.thread_spawn
Description: Reference for Dex.thread_spawn

### Function

# Dexthread_spawn

since: 1.0

#### Declaration [src]

    DexFuture*
    dex_thread_spawn (
      const char* thread_name,
      DexThreadFunc thread_func,
      gpointer user_data,
      GDestroyNotify user_data_destroy
    )

#### Description [src]

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

`thread_func` must return a `DexFuture`.

If this function is called from a thread that is not running a `DexScheduler` then the default scheduler will be used to call `user_data_destroy`.

If the resulting `DexFuture` 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.

Available since: 1.0

#### Parameters

`thread_name`

  Type: `const char*`

  The name for the thread.

  The argument can be `NULL`.
  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`thread_func`

  Type: `DexThreadFunc`

  The function to call on a thread.

`user_data`

  Type: `gpointer`

  Closure data for `thread_func`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`user_data_destroy`

  Type: `GDestroyNotify`

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

#### Return value

Type: `DexFuture`

A `DexFuture` that resolves or rejects the value or error returned from `thread_func` as a `DexFuture`.

The caller of the function takes ownership of the data, and is responsible for freeing it.