PHPackages                             appserver-io/concurrency - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. appserver-io/concurrency

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

appserver-io/concurrency
========================

It introduces abstract services and objects that provides easy handling for thread-safety, concurrency and sharing.

0.3.0(10y ago)34.3k24OSL-3.0PHPPHP &gt;=5.4.0

Since Apr 8Pushed 10y ago3 watchersCompare

[ Source](https://github.com/appserver-io/concurrency)[ Packagist](https://packagist.org/packages/appserver-io/concurrency)[ Docs](https://github.com/appserver-io/concurrency)[ RSS](/packages/appserver-io-concurrency/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (10)Used By (4)

Toolkit for Concurrent Programming in PHP with pthreads
=======================================================

[](#toolkit-for-concurrent-programming-in-php-with-pthreads)

[![Latest Stable Version](https://camo.githubusercontent.com/8ad4d27e3f23f48643441b8ec99d5a19ff6f39402510732e4f98b935658cbf07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6170707365727665722d696f2f636f6e63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/appserver-io/concurrency)[![Total Downloads](https://camo.githubusercontent.com/96de228c187f3e1ce432c8e7da921d7c49ca6858ae59f3e90769946a9aa8386e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6170707365727665722d696f2f636f6e63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/appserver-io/concurrency)[![License](https://camo.githubusercontent.com/b18c808c09ecc32d4dcaa79a189439b2f96ef839d6eb8203049cdafb09519268/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6170707365727665722d696f2f636f6e63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/appserver-io/concurrency)[![Build Status](https://camo.githubusercontent.com/10debebcc4b96b0b462930ba889a91f254bc716dd18a183dba830471b81e0f1e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6170707365727665722d696f2f636f6e63757272656e63792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](http://travis-ci.org/appserver-io/concurrency)[![Code Coverage](https://camo.githubusercontent.com/145286bee7b0ec608cc8730def50c98b330ba2801887272c01e4e0510ac61e4a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f6170707365727665722d696f2f636f6e63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/appserver-io/concurrency)[![Code Quality](https://camo.githubusercontent.com/5a78e2c4172bc8b75a509e2e51755a14cf8b2d41fbbd030876d84434a17f142c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f6170707365727665722d696f2f636f6e63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/appserver-io/concurrency)

What is it?
-----------

[](#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?
----

[](#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?
-----------

[](#how-to-use)

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

### The ExecutorService

[](#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

[](#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.

```
{
    "require": {
        "appserver-io/concurrency": "~0.2"
    },
}
```

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

```
