Questions tagged [php-pthread]

pthreads is an Object Orientated API that allows user-land multi-threading in PHP. It includes all the tools you need to create multi-threaded applications targeted at the Web or the Console. PHP applications can create, read, write, execute and synchronize with Threads, Workers and Threaded objects.

35 questions
1
vote
3 answers

PHP - Multi threading and pools

I am using Pool object in PHP pthread, and made the following test script, to see how the pooling should work. I tought, that what pooling should do, is to get a given number of tasks, open up a maximum x number of workers, and assign them the…
Adam Baranyai
  • 3,635
  • 3
  • 29
  • 68
1
vote
0 answers

PHP Multi Threading - Synchronizing a cache file between threads

I created a script, that, for a game situation tries to find the best possible solution. It does this, by simulating each and every possible move, and quantifying them, thus deciding which is the best move to take (which will result in the fastest…
Adam Baranyai
  • 3,635
  • 3
  • 29
  • 68
1
vote
1 answer

Multiprocessing in php using zend framework 3

Is it possible to multiprocess/multithread in php from a http request. Background I am working on a project where I expect some data (not from a user so data upload is consistent) to be uploaded to an api. I want to decouple the process such that if…
J.Ewa
  • 205
  • 3
  • 14
1
vote
0 answers

Can't overload Threaded::run from internal class

Here's an gist of what I'm attempting As you can see, it should overload run within pthreads_thread_entry parent, but it doesn't. start(); $test->join(); ?> Should print a thread id and sleep 10 seconds, but it…
JSON
  • 1,819
  • 20
  • 27
1
vote
2 answers

Laravel Commands, Pthreads and Closure

There is a need to perform a specific process multiple threads. I learned about the extension for php - pthreads. For example, a simple script outside Laravel works fine and I liked the results. I decided to move in Laravel, and faced with the…
Nik Gubin
  • 11
  • 1
  • 6
1
vote
1 answer

How to access variable of thread's constructor in run function?

class Test extends thread { function __construct(&$db,$userObj) { $this -> userObj = $userObj; print "Original:"; var_dump($db); $this->db = $db; print "InThread:"; var_dump($this->db); // as value…
Anubhav Singh
  • 432
  • 1
  • 5
  • 15
1
vote
1 answer

Using Threaded Object as Multidimensional Associative Array PHP Pthreads

My Problem I am trying to share a multi-dimensional associative array between different threads in a pthreads - based CLI application. The problem I am encountering is with assigning keys and values without overwriting previous keys. Simple…
FraserES
  • 356
  • 1
  • 8
0
votes
0 answers

How to install ZTS and pThreads in CentOS 7?

I have this installation of CentOS 7 linux in my server. Currently I use pcntl_fork but I find it a very crude solution and wanted to use pThreads. My problem is my server running CPanel/WHM has no option for installing pThreads. So, how do I…
gprialde
  • 1
  • 4
0
votes
0 answers

How to get threads working in PHP on Windows?

I want to run PHP Thread class code on Windows. I tried some manual installation guides like e.g. this one but they didn't work. PHP cannot load the pthreads DLL even though the file exists at this location: PHP Warning: PHP Startup: Unable to load…
BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
0
votes
1 answer

Trouble installing pthreads in Windows

PHP Version: 7.4.5 I am running a thread-safe version of PHP becuase after doing php -i|findstr "Thread" I get: Thread Safety => enabled Thread API => Windows Threads I downloaded the newest version pthreads (3.1.6) from:…
Jacob
  • 439
  • 6
  • 19
0
votes
0 answers

Pthread is not present

i want to install the pthreads extension in wampserver php 7.4.4 but i don't know why is not work. I followed this steps : 1) Download this file "php_pthreads-3.2.0-7.2-ts-vc15-x64" 2) Extract "pthreadVC2.dll" to my php root and add this to PATH 3)…
Errorj404
  • 43
  • 8
0
votes
0 answers

PHP pthreads async optimisation

After tinkering/testing stuffs for a few days with pthreads I manage to write a script from scratch that actually works for my needs. The point of my script is to run async like 500-1000 threads and keep creating new ones immediately when one is…
John Doe
  • 1
  • 1
0
votes
1 answer

PHP pthreads async with threads number gets stuck

I'm trying to achive a script that start threads async with a limit(5) and does wait if all threads are busy. If the threads are busy my script has to wait untill one is free and it should start another one but for some reasons does get stuck.…
John Doe
  • 1
  • 1
0
votes
1 answer

PHP Amp/Parallel. Please give me example about parallel function with pool

I have been stuck in my task about running functions in parallel. I has tried this library multi-threading pthreads from krakjoe, but I has limit knowledge about installations in ubuntu. I has tried this amp/parallel instead and other amphp. The…
0
votes
1 answer

PHP Multi Threading - How can I obtain the results from all the threads when they are ready?

I am trying to learn multithreading with PHP. I've installed PHP 7.2.14 with ZTS support, and looked over a lot of examples on the net, and afterwards, tried to create a simple script, to see if I understand the things that I've learned. The problem…
Adam Baranyai
  • 3,635
  • 3
  • 29
  • 68