Dex.Limiter.run

### Method

# Dex Limiterrun

unstable since: 1.2

#### Declaration [src]

    DexFuture*
    dex_limiter_run (
      DexLimiter* limiter,
      DexScheduler* scheduler,
      gsize stack_size,
      DexFiberFunc func,
      gpointer func_data,
      GDestroyNotify func_data_destroy
    )

#### Description [src]

Runs `func` while holding one permit from `limiter`.

The returned future resolves or rejects with the result of the spawned fiber. The permit is released automatically after the fiber resolves or rejects. If the returned future is discarded after the fiber starts, the fiber is allowed to complete so that the permit can be released.

Available since: 1.2

#### Parameters

`scheduler`

  Type: `DexScheduler`

  Scheduler to spawn `func` on, or `NULL` for the thread default.

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

`stack_size`

  Type: `gsize`

  Stack size for the spawned fiber, or zero to use the default.

`func`

  Type: `DexFiberFunc`

  Fiber function to run after a permit is acquired.

`func_data`

  Type: `gpointer`

  Closure data for `func`.

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

`func_data_destroy`

  Type: `GDestroyNotify`

  Destroy notify for `func_data`.

#### Return value

Type: `DexFuture`

A future representing the spawned fiber.

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