All Projects → cheprasov → php-parallel

cheprasov / php-parallel

Licence: MIT license
The class allows you to run multiple operations parallel in different processes and send results to the main process. Useful if you need to run multiple independent operations simultaneously, instead of sequential execution, or if you run several independent queries, for example, queries to different data bases.

Programming Languages

PHP
23972 projects - #3 most used programming language

Labels

Projects that are alternatives of or similar to php-parallel

noroutine
Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
Stars: ✭ 86 (+437.5%)
Mutual labels:  parallel
pwm
Parallel Wavelet Tree and Wavelet Matrix Construction
Stars: ✭ 17 (+6.25%)
Mutual labels:  parallel
XH5For
XDMF parallel partitioned mesh I/O on top of HDF5
Stars: ✭ 23 (+43.75%)
Mutual labels:  parallel
raptor
General, high performance algebraic multigrid solver
Stars: ✭ 50 (+212.5%)
Mutual labels:  parallel
sst-core
SST Structural Simulation Toolkit Parallel Discrete Event Core and Services
Stars: ✭ 82 (+412.5%)
Mutual labels:  parallel
useful-scripts
common useful script
Stars: ✭ 30 (+87.5%)
Mutual labels:  parallel
codeceptjs-bdd
⭐️ ⭐️⭐️ Migrated to Salesforce Open Source Platform - https://github.com/salesforce/codeceptjs-bdd
Stars: ✭ 24 (+50%)
Mutual labels:  parallel
CESM postprocessing
Project repository for the CESM python based post-processing code, documentation and issues tracking.
Stars: ✭ 63 (+293.75%)
Mutual labels:  parallel
machine-learning-data-pipeline
Pipeline module for parallel real-time data processing for machine learning models development and production purposes.
Stars: ✭ 22 (+37.5%)
Mutual labels:  parallel
dflow
A lightweight library for designing and executing workflows in .NET Core
Stars: ✭ 23 (+43.75%)
Mutual labels:  parallel
rTRNG
R package providing access and examples to TRNG C++ library
Stars: ✭ 17 (+6.25%)
Mutual labels:  parallel
pyfuncol
Functional collections extension functions for Python
Stars: ✭ 32 (+100%)
Mutual labels:  parallel
thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (+6418.75%)
Mutual labels:  parallel
video features
Extract video features from raw videos using multiple GPUs. We support RAFT and PWC flow frames as well as S3D, I3D, R(2+1)D, VGGish, CLIP, ResNet features.
Stars: ✭ 225 (+1306.25%)
Mutual labels:  parallel
pennylane-lightning
The PennyLane-Lightning plugin provides a fast state-vector simulator written in C++ for use with PennyLane
Stars: ✭ 28 (+75%)
Mutual labels:  parallel
Galaxy
Galaxy is an asynchronous parallel visualization ray tracer for performant rendering in distributed computing environments. Galaxy builds upon Intel OSPRay and Intel Embree, including ray queueing and sending logic inspired by TACC GraviT.
Stars: ✭ 18 (+12.5%)
Mutual labels:  parallel
SIMDArray
SIMD enhanced Array operations
Stars: ✭ 123 (+668.75%)
Mutual labels:  parallel
do
Simplest way to manage asynchronicity
Stars: ✭ 33 (+106.25%)
Mutual labels:  parallel
OpenABL
A domain-specific language for parallel and distributed agent-based simulations.
Stars: ✭ 24 (+50%)
Mutual labels:  parallel
malib
A parallel framework for population-based multi-agent reinforcement learning.
Stars: ✭ 341 (+2031.25%)
Mutual labels:  parallel

Parallel v1.2.0 for PHP >= 5.5

The class allows you to run multiple operations parallel in different thread and send results to the main process. Useful if you need to run multiple independent operations simultaneously, instead of sequential execution, or if you run several independent queries, for example, queries to different data bases.

Communications

Communications of data between processes is via one (or more) of storages:

  • APCu
  • Memcached
  • Redis

Using

<?php

require (dirname(__DIR__).'/vendor/autoload.php');

use Parallel\Parallel;
use Parallel\Storage\ApcuStorage;

// EXAMPLE, how to run parallel 3 operations.

// Using Parallel via ApcuStorage (APCu, see http://php.net/manual/ru/book.apcu.php)
$Parallel = new Parallel(new ApcuStorage());

// if you have not APCu, you can use Memcached or Redis as Storage.
// Note: you can't store objects in Memcached or Redis and you can't store binary strings (use <base64> functions)

//    $Parallel = new Parallel(new \Parallel\Storage\MemcachedStorage([
//        'servers' => [['127.0.0.1', 11211]]
//    ]));

//    $Parallel = new Parallel(new \Parallel\Storage\RedisStorage([
//        'server' => 'tcp://127.0.0.1:6379'
//    ]));

$time = microtime(true);

// 1st operation
$Parallel->run('foo', function() {
    // You can use Parallel inside run function by creating new objects Parallel.
    // Example: $Parallel = new Parallel(new \Parallel\Storage\ApcuStorage());
    sleep(2);
    return ['hello' => 'world'];
});

// 2nd operation
$Parallel->run('obj', function() {
    sleep(2);
    return (object) ['a' => 1, 'b' => 2, 'c' => 3];
});

// 3th operation
// do some thing ...
sleep(2);

// waiting for <foo> and <obj> and get results.
// use wait() without parameters for wait all forks. Example: $Parallel->wait();
$result = $Parallel->wait(['foo', 'obj']);

print_r($result);
print_r(microtime(true) - $time);
// 3 parallel operations by 2 seconds take about 2 seconds, instead 6 seconds.

//    Array
//    (
//        [foo] => Array
//            (
//                [hello] => world
//            )
//
//        [obj] => stdClass Object
//            (
//                [a] => 1
//                [b] => 2
//                [c] => 3
//            )
//    )
//    2.0130307674408

Installation

Composer

Download composer:

wget -nc http://getcomposer.org/composer.phar

and add dependency to your project:

php composer.phar require cheprasov/php-parallel

Running tests

To run tests type in console:

./vendor/bin/phpunit

Something doesn't work

Feel free to fork project, fix bugs and finally request for pull

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].