Download the PHP package futoin/core-php-ri-asyncsteps without Composer

On this page you can find all versions of the php package futoin/core-php-ri-asyncsteps. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package core-php-ri-asyncsteps

Build Status

Reference implementation of:

FTN12: FutoIn Async API
Version: 1.7

Spec: FTN12: FutoIn Async API v1.x

Web Site

About

Adds classical linear program flow structure to async programming supporting exceptions. error handlers, timeouts, unlimited number of sub-steps, execution parallelism and job state/context variables.

There is little benefit of using this tool in classical PHP aproach of one-request-one-execution approach. However, it is base for FutoIn Invoker and Executor implementation, which target at daemon-like execution pattern.

It should be possible to use any other async framework from AsyncSteps by using setCancel() and/or setTimeout() methods which allow step completion without success() or error() result. Specific step-associated AsyncSteps interface will be valid for success() or error() call on external event.

It also possible to use FutoIn AsyncSteps from any other event framework. Just make sure to notify external framework from the top most error handler (for errors) and last step (for success).

To minimize cost of closure creation on repetitive execution, a special feature of "model" step is available: model step is created as usual, but must never get executed. It possible to copy steps and state variables using AsyncSteps#copyFrom() to a newly created object.

Installation

Command line:

and/or composer.json:

Concept

NOTE: copy&paste from FTN12: FutoIn Async API v1.x

This interface was born as a secondary option for executor concept. However, it quickly became clear that async/reactor/proactor/light threads/etc. should be base for scalable high performance server implementations, even though it is more difficult for understanding and/or debugging. Traditional synchronous program flow becomes an addon on top of asynchronous base for legacy code and/or too complex logic.

Program flow is split into non-blocking execution steps, represented with execution callback function. Processing Unit (eg. CPU) halting/ spinning/switching-to-another-task is seen as a blocking action in program flow.

Any step must not call any of blocking functions, except for synchronization with guaranteed minimal period of lock acquisition. Note: under minimal period, it is assumed that any acquired lock is immediately released after action with O(1) complexity and no delay caused by programmatic suspension/locking of executing task

Every step is executed sequentially. Success result of any step becomes input for the following step.

Each step can have own error handler. Error handler is called, if AsyncSteps.error() is called within step execution or any of its sub-steps. Typical behavior is to ignore error and continue or to make cleanup actions and complete job with error.

Each step can have own sequence of sub-steps. Sub-steps can be added only during that step execution. Sub-step sequence is executed after current step execution is finished.

If there are any sub-steps added then current step must not call AsyncSteps.success() or AsyncSteps.error(). Otherwise, InternalError is raised.

It is possible to create a special "parallel" sub-step and add independent sub-steps to it. Execution of each parallel sub-step is started all together. Parallel step completes with success when all sub-steps complete with success. If error is raised in any sub-step of parallel step then all other sub-steps are canceled.

Out-of-order cancel of execution can occur by timeout, execution control engine decision (e.g. Invoker disconnect) or failure of sibling parallel step. Each step can install custom on-cancel handler to free resources and/or cancel external jobs. After cancel, it must be safe to destroy AsyncSteps object.

AsyncSteps must be used in Executor request processing. The same [root] AsyncSteps object must be used for all asynchronous tasks within given request processing.

AsyncSteps may be used by Invoker implementation.

AsyncSteps must support derived classes in implementation-defined way. Typical use case: functionality extension (e.g. request processing API).

For performance reasons, it is not economical to initialize AsyncSteps with business logic every time. Every implementation must support platform-specific AsyncSteps cloning/duplicating.

1.1. Levels

When AsyncSteps (or derived) object is created all steps are added sequentially in Level 0 through add() and/or parallel(). Note: each parallel() is seen as a step.

After AsyncSteps execution is initiated, each step of Level 0 is executed. All sub-steps are added in Level n+1. Example:

add() -> Level 0 #1
    add() -> Level 1 #1
        add() -> Level 2 #1
        parallel() -> Level 2 #2
        add() -> Level 2 #3
    parallel() -> Level 1 #2
    add() -> Level 1 #3
parallel() -> Level 0 #2
add() -> Level 0 #3

Execution cannot continue to the next step of current Level until all steps of higher Level are executed.

The execution sequence would be:

Level 0 add #1
Level 1 add #1
Level 2 add #1
Level 2 parallel #2
Level 2 add #3
Level 1 parallel #2
Level 1 add #3
Level 0 parallel #2
Level 0 add #3

1.2. Error handling

Due to not linear programming, classic try/catch blocks are converted into execute/onerror. Each added step may have custom error handler. If error handler is not specified then control passed to lower Level error handler. If non is defined then execution is aborted.

Example:

add( -> Level 0
    func( as ){
        print( "Level 0 func" )
        add( -> Level 1
            func( as ){
                print( "Level 1 func" )
                as.error( "myerror" )
            },
            onerror( as, error ){
                print( "Level 1 onerror: " + error )
                as.error( "newerror" )
            }
        )
    },
    onerror( as, error ){
        print( "Level 0 onerror: " + error )
        as.success( "Prm" )
    }
)
add( -> Level 0
    func( as, param ){
        print( "Level 0 func2: " + param )
        as.success()
    }
)

Output would be:

Level 0 func
Level 1 func
Level 1 onerror: myerror
Level 0 onerror: newerror
Level 0 func2: Prm

In synchronous way, it would look like:

variable = null

try
{
    print( "Level 0 func" )

    try
    {
        print( "Level 1 func" )
        throw "myerror"
    }
    catch ( error )
    {
        print( "Level 1 onerror: " + error )
        throw "newerror"
    }
}
catch( error )
{
    print( "Level 0 onerror: " + error )
    variable = "Prm"
}

print( "Level 0 func2: " + variable )

1.3. Wait for external resources

Very often, execution of step cannot continue without waiting for external event like input from network or disk. It is forbidden to block execution in event waiting. As a solution, there are special setTimeout() and setCancel() methods.

Example:

add(
    func( as ){
        socket.read( function( data ){
            as.success( data )
        } )

        as.setCancel( function(){
            socket.cancel_read()
        } )

        as.setTimeout( 30_000 ) // 30 seconds
    },
    onerror( as, error ){
        if ( error == timeout ) {
            print( "Timeout" )
        }
        else
        {
            print( "Read Error" )
        }
    }
)

1.4. Parallel execution abort

Definition of parallel steps makes no sense to continue execution if any of steps fails. To avoid excessive time and resources spent on other steps, there is a concept of canceling execution similar to timeout above.

Example:

as.parallel()
    .add(
        func( as ){
            as.setCancel( function(){ ... } )

            // do parallel job #1
            as.state()->result1 = ...;
        }
    )
    .add(
        func( as ){
            as.setCancel( function(){ ... } )

            // do parallel job #1
            as.state()->result2 = ...;
        }
    )
    .add(
        func( as ){
            as.error( "Some Error" )
        }
    )
as.add(
    func( as ){
        print( as.state()->result1 + as.state->result2 )
        as.success()
    }
)

1.5. AsyncSteps cloning

In long living applications the same business logic may be re-used multiple times during execution.

In a REST API server example, complex business logic can be defined only once and stored in a kind of AsyncSteps object repository. On each request, a reference object from the repository would be copied for actual processing with minimal overhead.

However, there would be no performance difference in sub-step definition unless its callback function is also created at initialization time, but not at parent step execution time (the default concept). So, it should be possible to predefine those as well and copy/inherit during step execution. Copying steps must also involve copying of state variables.

Example:

AsyncSteps req_repo_common;
req_repo_common.add(func( as ){
    as.add( func( as ){ ... } );
    as.copyFrom( as.state().business_logic );
    as.add( func( as ){ ... } );
});

AsyncSteps req_repo_buslog1;
req_repo_buslog1
    .add(func( as ){ ... })
    .add(func( as ){ ... });

AsyncSteps actual_exec = copy req_repo_common;
actual_exec.state().business_logic = req_repo_buslog1;
actual_exec.execute();

However, this approach only make sense for deep performance optimizations.

1.6. Implicit as.success()

If there are no sub-steps added, no timeout set and no cancel handler set then implicit as.success() call is assumed to simplify code and increase efficiency.

as.add(func( as ){
    doSomeStuff( as );
})

1.7. Error Info and Last Exception

Pre-defined state variables:

Error code is not always descriptive enough, especially, if it can be generated in multiple ways. As a convention special "error_info" state field should hold descriptive information of the last error. Therefore, as.error() is extended with optional parameter error_info.

"last_exception" state variables may hold the last exception object caught, if feasible to implement. It should be populated with FutoIn errors as well.

1.8. Async Loops

Almost always, async program flow is not linear. Sometimes, loops are required.

Basic principals of async loops:

    as.loop( func( as ){
        call_some_library( as );
        as.add( func( as, result ){
            if ( !result )
            {
                // exit loop
                as.break();
            }
        } );
    } )

Inner loops and identifiers:

    // start loop
    as.loop( 
        func( as ){
            as.loop( func( as ){
                call_some_library( as );
                as.add( func( as, result ){
                    if ( !result )
                    {
                        // exit loop
                        as.continue( "OUTER" );
                    }

                    as.success( result );
                } );
            } );

            as.add( func( as, result ){
                // use it somehow
                as.success();
            } );
        },
        "OUTER"
    )

Loop n times.

    as.repeat( 3, func( as, i ){
        print( 'Iteration: ' + i )
    } )

Traverse through list or map:

    as.forEach(
        [ 'apple', 'banana' ],
        func( as, k, v ){
            print( k + " = " + v )
        }
    )

1.8.1. Termination

Normal loop termination is performed either by loop condition (e.g. as.forEach(), as.repeat()) or by as.break() call. Normal termination is seen as as.success() call.

Abnormal termination is possible through as.error(), including timeout, or external as.cancel(). Abnormal termination is seen as as.error() call.

1.9. The Safety Rules of libraries with AsyncSteps interface

  1. as.success() should be called only in top-most function of the step (the one passed to as.add() directly)
  2. setCancel() and/or setTimeout() must be called only in top most function as repeated call overrides in scope of step

1.10. Reserved keyword name clash

If any of API identifiers clashes with reserved word or has illegal symbols then implementation-defined name mangling is allowed, but with the following guidelines in priority.

Pre-defined alternative method names, if the default matches language-specific reserved keywords:

Examples

Simple steps

Result:

External event wait

Result:

Model steps (avoid closure creation overhead on repetitive execution)

Result. Please note the order as only the first step is executed in the loop. The rest is executed quasi-parallel by nature of async programming. The model_as closure gets executed 6 times, but created only once.

API documentation

API Index

FutoIn\RI\AsyncSteps

AsyncSteps reference implementation as per "FTN12: FutoIn Async API"

Methods

__construct

mixed FutoIn\RI\AsyncSteps::__construct(object $state)

Init

Arguments

add

\FutoIn\AsyncSteps FutoIn\RI\AsyncSteps::add(callable $func, callable $onerror)

Add \$func step executor to end of current AsyncSteps level queue

Arguments

copyFrom

\FutoIn\AsyncSteps FutoIn\RI\AsyncSteps::copyFrom(\FutoIn\RI\AsyncSteps $other)

Copy steps from other AsyncSteps, useful for sub-step cloning

Arguments

parallel

\FutoIn\AsyncSteps FutoIn\RI\AsyncSteps::parallel(callable $onerror)

Create special object to queue steps for execution in parallel

Arguments

state

\StdClass FutoIn\RI\AsyncSteps::state()

Access AsyncSteps state object

success

mixed FutoIn\RI\AsyncSteps::success()

Set "success" state of current step execution

successStep

mixed FutoIn\RI\AsyncSteps::successStep()

Call success() or add efficient dummy step equal to as.success() in behavior (depending on presence of other sub-steps)

error

mixed FutoIn\RI\AsyncSteps::error(string $name, string $error_info)

Set "error" state of current step execution

Arguments

setTimeout

mixed FutoIn\RI\AsyncSteps::setTimeout(integer $timeout_ms)

Delay further execution until as.success() or as.error() is called

Arguments

__invoke

mixed FutoIn\RI\AsyncSteps::__invoke()

PHP-specific alias for success()

setCancel

mixed FutoIn\RI\AsyncSteps::setCancel($oncancel)

Set cancellation callback

Arguments

execute

mixed FutoIn\RI\AsyncSteps::execute()

Start execution of AsyncSteps

It can be called only on root instance of AsyncSteps

cancel

mixed FutoIn\RI\AsyncSteps::cancel()

Cancel execution of AsyncSteps

It can be called only on root instance of AsyncSteps

loop

mixed FutoIn\RI\AsyncSteps::loop(callable $func, string $label)

Execute loop until as.break() is called

Arguments

loopForEach

mixed FutoIn\RI\AsyncSteps::loopForEach(array $maplist, callable $func, string $label)

For each map or list element call func( as, key, value )

Arguments

repeat

mixed FutoIn\RI\AsyncSteps::repeat(integer $count, callable $func, string $label)

Call func(as, i) for count times

Arguments

breakLoop

mixed FutoIn\RI\AsyncSteps::breakLoop(string $label)

Break execution of current loop, throws exception

Arguments

continueLoop

mixed FutoIn\RI\AsyncSteps::continueLoop(string $label)

Ccontinue loop execution from the next iteration, throws exception

Arguments

__set

mixed FutoIn\RI\AsyncSteps::__set(string $name, mixed $value)

state() access through AsyncSteps interface / set value

Arguments

__get

mixed FutoIn\RI\AsyncSteps::__get(string $name)

state() access through AsyncSteps interface / get value

Arguments

__isset

boolean FutoIn\RI\AsyncSteps::__isset(string $name)

state() access through AsyncSteps interface / check value exists

Arguments

__unset

mixed FutoIn\RI\AsyncSteps::__unset(string $name)

state() access through AsyncSteps interface / delete value

Arguments

FutoIn\RI\AsyncTool

Wrapper interface for singleton AsyncTools implementation

Methods

init

mixed FutoIn\RI\AsyncTool::init(\FutoIn\RI\Details\AsyncToolImpl $impl)

Install Async Tool implementation

Arguments

callLater

mixed FutoIn\RI\AsyncTool::callLater(callable $cb, integer $delay_ms)

Schedule $cb for later execution after $delays_ms milliseconds

Arguments

cancelCall

boolean FutoIn\RI\AsyncTool::cancelCall(mixed $ref)

Cancel previously scheduled $ref item

Arguments

FutoIn\RI\AsyncToolTest

Async Tool implementation for testing purposes

Install like \FutoIn\RI\AsyncToolTest::init().

The primary feature is predictive event firing for debugging and Unit Testing through nextEvent()

Methods

nextEvent

mixed FutoIn\RI\AsyncToolTest::nextEvent()

Wait and execute the next item in queue, if any

hasEvents

boolean FutoIn\RI\AsyncToolTest::hasEvents()

Check if any item is scheduled (for unit testing)

resetEvents

mixed FutoIn\RI\AsyncToolTest::resetEvents()

Reset event queue (for unit testing)

getEvents

array FutoIn\RI\AsyncToolTest::getEvents()

Get internal item queue (for unit testing)

run

mixed FutoIn\RI\AsyncToolTest::run()

Run event loop until last event pending

__construct

mixed FutoIn\RI\Details\AsyncToolImpl::__construct()

Any derived class should call this c-tor for future-compatibility

init

mixed FutoIn\RI\Details\AsyncToolImpl::init()

Install Async Tool implementation, call using derived class

callLater

mixed FutoIn\RI\Details\AsyncToolImpl::callLater(callable $cb, integer $delay_ms)

Schedule $cb for later execution after $delays_ms milliseconds

Arguments

cancelCall

mixed FutoIn\RI\Details\AsyncToolImpl::cancelCall(mixed $ref)

Cancel previously scheduled $ref item

Arguments

FutoIn\RI\Details\AsyncStepsProtection

Internal class to organize AsyncSteps levels during execution

Properties

$root

private mixed $root

$adapter_stack

private mixed $adapter_stack

$_onerror

public mixed $_onerror

$_oncancel

public mixed $_oncancel

$_queue

public mixed $_queue = null

$_limit_event

public mixed $_limit_event = null

Methods

__construct

mixed FutoIn\RI\Details\AsyncStepsProtection::__construct($root, $adapter_stack)

Arguments

_cleanup

mixed FutoIn\RI\Details\AsyncStepsProtection::_cleanup()

_sanityCheck

mixed FutoIn\RI\Details\AsyncStepsProtection::_sanityCheck()

add

mixed FutoIn\RI\Details\AsyncStepsProtection::add(callable $func, callable $onerror)

Arguments

parallel

mixed FutoIn\RI\Details\AsyncStepsProtection::parallel(callable $onerror)

Arguments

state

mixed FutoIn\RI\Details\AsyncStepsProtection::state()

success

mixed FutoIn\RI\Details\AsyncStepsProtection::success()

successStep

mixed FutoIn\RI\Details\AsyncStepsProtection::successStep()

error

mixed FutoIn\RI\Details\AsyncStepsProtection::error($name, $error_info)

Arguments

setTimeout

mixed FutoIn\RI\Details\AsyncStepsProtection::setTimeout($timeout_ms)

Arguments

__invoke

mixed FutoIn\RI\Details\AsyncStepsProtection::__invoke()

setCancel

mixed FutoIn\RI\Details\AsyncStepsProtection::setCancel(callable $oncancel)

Arguments

execute

mixed FutoIn\RI\Details\AsyncStepsProtection::execute()

cancel

mixed FutoIn\RI\Details\AsyncStepsProtection::cancel()

copyFrom

mixed FutoIn\RI\Details\AsyncStepsProtection::copyFrom(\FutoIn\AsyncSteps $other)

Arguments

__clone

mixed FutoIn\RI\Details\AsyncStepsProtection::__clone()

loop

mixed FutoIn\RI\Details\AsyncStepsProtection::loop(callable $func, string $label)

Execute loop until as.break() is called

Arguments

loopForEach

mixed FutoIn\RI\Details\AsyncStepsProtection::loopForEach(array $maplist, callable $func, string $label)

For each map or list element call func( as, key, value )

Arguments

repeat

mixed FutoIn\RI\Details\AsyncStepsProtection::repeat(integer $count, callable $func, string $label)

Call func(as, i) for count times

Arguments

breakLoop

mixed FutoIn\RI\Details\AsyncStepsProtection::breakLoop(string $label)

Break execution of current loop, throws exception

Arguments

continueLoop

mixed FutoIn\RI\Details\AsyncStepsProtection::continueLoop(string $label)

Ccontinue loop execution from the next iteration, throws exception

Arguments

__set

mixed FutoIn\RI\Details\AsyncStepsProtection::__set(string $name, mixed $value)

state() access through AsyncSteps interface / set value

Arguments

__get

mixed FutoIn\RI\Details\AsyncStepsProtection::__get(string $name)

state() access through AsyncSteps interface / get value

Arguments

__isset

boolean FutoIn\RI\Details\AsyncStepsProtection::__isset(string $name)

state() access through AsyncSteps interface / check value exists

Arguments

__unset

mixed FutoIn\RI\Details\AsyncStepsProtection::__unset(string $name)

state() access through AsyncSteps interface / delete value

Arguments

FutoIn\RI\Details\AsyncToolImpl

Abstract base for AsyncTool implementation

Methods

__construct

mixed FutoIn\RI\Details\AsyncToolImpl::__construct()

Any derived class should call this c-tor for future-compatibility

init

mixed FutoIn\RI\Details\AsyncToolImpl::init()

Install Async Tool implementation, call using derived class

callLater

mixed FutoIn\RI\Details\AsyncToolImpl::callLater(callable $cb, integer $delay_ms)

Schedule $cb for later execution after $delays_ms milliseconds

Arguments

cancelCall

mixed FutoIn\RI\Details\AsyncToolImpl::cancelCall(mixed $ref)

Cancel previously scheduled $ref item

Arguments

FutoIn\RI\Details\ParallelStep

Internal class to organize Parallel step execution

Properties

$root

private mixed $root

$as

private mixed $as

$parallel_steps

private mixed $parallel_steps

$complete_count

private mixed $complete_count

Methods

__construct

mixed FutoIn\RI\Details\ParallelStep::__construct($root, $async_iface)

Arguments

_cleanup

mixed FutoIn\RI\Details\ParallelStep::_cleanup()

add

mixed FutoIn\RI\Details\ParallelStep::add(callable $func, callable $onerror)

Arguments

parallel

mixed FutoIn\RI\Details\ParallelStep::parallel(callable $onerror)

Arguments

state

mixed FutoIn\RI\Details\ParallelStep::state()

success

mixed FutoIn\RI\Details\ParallelStep::success()

successStep

mixed FutoIn\RI\Details\ParallelStep::successStep()

error

mixed FutoIn\RI\Details\ParallelStep::error($name, $errorinfo)

Arguments

__invoke

mixed FutoIn\RI\Details\ParallelStep::__invoke()

setTimeout

mixed FutoIn\RI\Details\ParallelStep::setTimeout($timeout_ms)

Arguments

setCancel

mixed FutoIn\RI\Details\ParallelStep::setCancel(callable $oncancel)

Arguments

execute

mixed FutoIn\RI\Details\ParallelStep::execute()

copyFrom

mixed FutoIn\RI\Details\ParallelStep::copyFrom(\FutoIn\AsyncSteps $other)

Arguments

__clone

mixed FutoIn\RI\Details\ParallelStep::__clone()

loop

mixed FutoIn\RI\Details\ParallelStep::loop(callable $func, string $label)

Execute loop until as.break() is called

Arguments

loopForEach

mixed FutoIn\RI\Details\ParallelStep::loopForEach(array $maplist, callable $func, string $label)

For each map or list element call func( as, key, value )

Arguments

repeat

mixed FutoIn\RI\Details\ParallelStep::repeat(integer $count, callable $func, string $label)

Call func(as, i) for count times

Arguments

breakLoop

mixed FutoIn\RI\Details\ParallelStep::breakLoop(string $label)

Break execution of current loop, throws exception

Arguments

continueLoop

mixed FutoIn\RI\Details\ParallelStep::continueLoop(string $label)

Ccontinue loop execution from the next iteration, throws exception

Arguments

__set

mixed FutoIn\RI\Details\ParallelStep::__set(string $name, mixed $value)

state() access through AsyncSteps interface / set value

Arguments

__get

mixed FutoIn\RI\Details\ParallelStep::__get(string $name)

state() access through AsyncSteps interface / get value

Arguments

__isset

boolean FutoIn\RI\Details\ParallelStep::__isset(string $name)

state() access through AsyncSteps interface / check value exists

Arguments

__unset

mixed FutoIn\RI\Details\ParallelStep::__unset(string $name)

state() access through AsyncSteps interface / delete value

Arguments

FutoIn\RI\Details\StateObject

Internal class to organize state object.

Properties

$error_info

public mixed $error_info = null

$last_exception

public mixed $last_exception = null

$_loop_term_label

public mixed $_loop_term_label = null

FutoIn\RI\ScopedSteps

Not standard API. Use for synchronous invocation of AsyncSteps, IF there is no true event loop.

Example: $s = new ScopedSteps; $s->add( ... )->add( ... ); $s->run();

\note AsyncTool must be initialized with AsyncToolTest or not initalized at all

Methods

__construct

mixed FutoIn\RI\AsyncSteps::__construct(object $state)

Init

Arguments

run

mixed FutoIn\RI\ScopedSteps::run()

Execute all steps until nothing is left

add

\FutoIn\AsyncSteps FutoIn\RI\AsyncSteps::add(callable $func, callable $onerror)

Add \$func step executor to end of current AsyncSteps level queue

Arguments

copyFrom

\FutoIn\AsyncSteps FutoIn\RI\AsyncSteps::copyFrom(\FutoIn\RI\AsyncSteps $other)

Copy steps from other AsyncSteps, useful for sub-step cloning

Arguments

parallel

\FutoIn\AsyncSteps FutoIn\RI\AsyncSteps::parallel(callable $onerror)

Create special object to queue steps for execution in parallel

Arguments

state

\StdClass FutoIn\RI\AsyncSteps::state()

Access AsyncSteps state object

success

mixed FutoIn\RI\AsyncSteps::success()

Set "success" state of current step execution

successStep

mixed FutoIn\RI\AsyncSteps::successStep()

Call success() or add efficient dummy step equal to as.success() in behavior (depending on presence of other sub-steps)

error

mixed FutoIn\RI\AsyncSteps::error(string $name, string $error_info)

Set "error" state of current step execution

Arguments

setTimeout

mixed FutoIn\RI\AsyncSteps::setTimeout(integer $timeout_ms)

Delay further execution until as.success() or as.error() is called

Arguments

__invoke

mixed FutoIn\RI\AsyncSteps::__invoke()

PHP-specific alias for success()

setCancel

mixed FutoIn\RI\AsyncSteps::setCancel($oncancel)

Set cancellation callback

Arguments

execute

mixed FutoIn\RI\AsyncSteps::execute()

Start execution of AsyncSteps

It can be called only on root instance of AsyncSteps

cancel

mixed FutoIn\RI\AsyncSteps::cancel()

Cancel execution of AsyncSteps

It can be called only on root instance of AsyncSteps

loop

mixed FutoIn\RI\AsyncSteps::loop(callable $func, string $label)

Execute loop until as.break() is called

Arguments

loopForEach

mixed FutoIn\RI\AsyncSteps::loopForEach(array $maplist, callable $func, string $label)

For each map or list element call func( as, key, value )

Arguments

repeat

mixed FutoIn\RI\AsyncSteps::repeat(integer $count, callable $func, string $label)

Call func(as, i) for count times

Arguments

breakLoop

mixed FutoIn\RI\AsyncSteps::breakLoop(string $label)

Break execution of current loop, throws exception

Arguments

continueLoop

mixed FutoIn\RI\AsyncSteps::continueLoop(string $label)

Ccontinue loop execution from the next iteration, throws exception

Arguments

__set

mixed FutoIn\RI\AsyncSteps::__set(string $name, mixed $value)

state() access through AsyncSteps interface / set value

Arguments

__get

mixed FutoIn\RI\AsyncSteps::__get(string $name)

state() access through AsyncSteps interface / get value

Arguments

__isset

boolean FutoIn\RI\AsyncSteps::__isset(string $name)

state() access through AsyncSteps interface / check value exists

Arguments

__unset

mixed FutoIn\RI\AsyncSteps::__unset(string $name)

state() access through AsyncSteps interface / delete value

Arguments


All versions of core-php-ri-asyncsteps with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
futoin/core-php-api Version ^0.7
ext-spl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package futoin/core-php-ri-asyncsteps contains the following files

Loading the files please wait ....