### Method

# Dex Scheduler spawn_coroutine

unstable since: 1.2

#### Declaration [src]

    DexFuture*
    dex_scheduler_spawn_coroutine (
      DexScheduler* scheduler,
      DexCoroutineFunc func,
      gpointer user_data,
      GDestroyNotify user_data_destroy
    )

#### Description [src]

Request `scheduler` to spawn a `DexCoroutine` and execute `func` with user data.

If the function returns `NULL` while suspended, it should have set an awaited future in its context using one of the `DEX_COROUTINE_SUSPEND_*` helpers.

Available since: 1.2

#### Parameters

`scheduler`

  Type: `DexScheduler`

  A `DexScheduler`.

  The argument can be `NULL`.

`func`

  Type: `DexCoroutineFunc`

  Coroutine entrypoint.

`user_data`

  Type: `gpointer`

  User data passed to the coroutine entrypoint.

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

`user_data_destroy`

  Type: `GDestroyNotify`

  Destroy notify for `user_data`.

#### Return value

Type: `DexFuture`

A `DexFuture` that will resolve or reject when `func` finishes or returns an error.

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