Giter Club home page Giter Club logo

pthreads-polyfill's Introduction

pthreads-polyfill

Build Status

pthreads-polyfill aims to satisfy the API requirements of pthreads, such that code written to depend on pthreads will work when pthreads is not, or can not be loaded.

pthreads-polyfill does not implement the same execution model, for obvious reasons, and has no external dependencies.

pthreads-polyfill will fill for v2 or v3, however behaviour is consistent with v3, which is the version new projects should target.

Testing

pthreads-polyfill is distributed with some unit tests, these tests should pass with and without pthreads loaded.

Testing pthreads-polyfill

phpunit tests

If pthreads is loaded by your configuration the polyfill will not be used.

Testing code coverage for pthreads-polyfill

phpdbg -nqrr vendor/bin/phpunit tests --coverage-text

pthreads-polyfill's People

Contributors

anahkiasen avatar cmyker avatar kelunik avatar krakjoe avatar stof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pthreads-polyfill's Issues

PHP5.6 is not supported?

I am getting the below error in PHP 5.6.32.

PHP Parse error: syntax error, unexpected ':', expecting ';' or '{' in /var/www/c9825/protected/vendor/krakjoe/pthreads-polyfill/src/Threaded.php on line 129

Please mention the minimum support PHP version in the composer file?

PhpStorm inspection false positive

PhpStorm inspection triggers on the absent "setGarbage()" method. Writes me "class must be declared abstract or implement setGrabage method". pthread is supposed to be version 3.

Constants are not defined

The polyfill polyfills the classes but not the constants such as PTHREADS_INHERIT_NONE, could those be added as well?

Worker::collect never ends

Not entirely sure why but Worker::collect never returns 0, even when all jobs have been technically processed (ie. I know that they've all ran). It seems to boil down to jobs not being properly moved from Worker::$stacked to Worker::$gc, at least that's what I've found so far.

If I modify the method to only return count($this->gc) all my jobs are processed and the loop ends, but I'm not sure if that's supposed to be correct?

Seems to be not multi-threaded or not asynchronous

I tried my working example of multi-threaded code, and it seems to be not multi-threaded or asynchronous. The following example should output like below:

Thread: 1 has started, sleeping for 2 
Thread: 2 has started, sleeping for 3 
Thread: 3 has started, sleeping for 1
Thread: 3 has finished
Thread: 1 has finished
Thread: 2 has finished

But when I run it using polyfill its output is not asynchronous:

Thread: 1 has started, sleeping for 2  // will really wait for 2 seconds, blocking thread 2 and 3
Thread: 1 has finished
Thread: 2 has started, sleeping for 3 
Thread: 2 has finished
Thread: 3 has started, sleeping for 1
Thread: 3 has finished

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.