Download the PHP package appserver-io/concurrency without Composer

On this page you can find all versions of the php package appserver-io/concurrency. 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 concurrency

Toolkit for Concurrent Programming in PHP with pthreads

Latest Stable Version Total Downloads License Build Status Code Coverage Code Quality

What is it?

The concurrency toolkit introduces abstract services and objects that provides easy handling for thread-safety, concurrency programming and data sharing all written in PHP-Userland.

Why?

If you are implementing multithreaded functionality you're always fighting against the same problems called Race-Conditions, Deadlocks etc... When sharing simple data or even plain PHP objects between threads you have to make sure, that everything is synchronized (Thread-safe) in any logic of your code. This Toolkit mostly helps you to avoid those problems by providing abstract services and object written in PHP-Userland.

How to use?

This toolkit is in early-stage development. Please use with caution.

The ExecutorService

It allows you to hold plain PHP objects persistent as singleton in memory accessible everywhere in your code even in different thread contexts. You can keep those plain PHP objects easily thread-safe or call certain methods asynchronous by using simple annotations like @Synchronized or @Asynchronous in method docblocks.

How it works

If you want to use the concurrency toolkit in your project you have to add it to the composer dependencies composer.json and do a composer update afterwards.

At first you have to initialise the ExecutorService in a main PHP script main.php.

Lets say you want to build a simple storage PHP object to share data all over your multithreaded implementations. The storage object could look like this. Create Storage.php and add:

Maybe you've noticed the method docblock annotations we used here. Methods marked with @Synchronized can not be called more than once at the same time. That means the $data array will always be synchronized when using all(), set(), get(), del() or inc(). Methods using @Asynchronous are called asynchronously. So if the dump() method is called it will dump the $data array while not blocking your main logic execution.

To make use of the storage object we have to create a multithreaded task simulation that should represent multithreaded business logic. So create Task.php and add:

Now bring all together and enhance the main script main.php:

If you call main.php with a thread-safe compiled php version where pthreads ext is installed as it`s provided by appserver.io runtime for example the result should look like this:

The executor service has some internal function as described here:

Method Description
__return Returns the plain entity object from executor thread context if its serializable in its actual state
__invoke(closure) Executes the callable in executor thread context. It will provide $self as function argument which references the plain entity object. Example usage:
$executorServiceEntity->__invoke(function($self) { $self->doSomething() }); 
__reset() Resets the plaing entity object in executor service context
__shutdown() Shutdown the executor service thread

Issues

In order to bundle our efforts we would like to collect all issues regarding this package in the main project repository's issue tracker. Please reference the originating repository as the first element of the issue title e.g.: [appserver-io/<ORIGINATING_REPO>] A issue I am having


All versions of concurrency with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
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 appserver-io/concurrency contains the following files

Loading the files please wait ....