You are here

function task in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/promises/src/functions.php \GuzzleHttp\Promise\task()

Adds a function to run in the task queue when it is next `run()` and returns a promise that is fulfilled or rejected with the result.

Parameters

callable $task Task function to run.:

Return value

PromiseInterface

13 string references to 'task'
AlterTest::testAlterChangeConditional in core/modules/system/src/Tests/Database/AlterTest.php
Tests that we can alter a query's conditionals.
AlterTest::testAlterWithJoin in core/modules/system/src/Tests/Database/AlterTest.php
Tests that we can alter the joins on a query.
DatabaseTestController::testTablesort in core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
Runs a tablesort query and returns the results.
DatabaseTestController::testTablesortFirst in core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
Runs a tablesort query with a second order_by after and returns the results.
SelectComplexTest::testCountQueryDistinct in core/modules/system/src/Tests/Database/SelectComplexTest.php
Tests that we can generate a count query from a query with distinct.

... See full list

File

vendor/guzzlehttp/promises/src/functions.php, line 38

Namespace

GuzzleHttp\Promise

Code

function task(callable $task) {
  $queue = queue();
  $promise = new Promise([
    $queue,
    'run',
  ]);
  $queue
    ->add(function () use ($task, $promise) {
    try {
      $promise
        ->resolve($task());
    } catch (\Exception $e) {
      $promise
        ->reject($e);
    }
  });
  return $promise;
}