Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use PHP // Thread // Mutex // Cond

PHP apparently supports now a Thread class. There is also a Mutex and Cond class. One need nevertheless to compile it with the good options and add a PECL extension to have it.

Is there a good tutorial where to start ? Something that shows clearly the fair use of each Class / Method.

I just don't know how to deal with these classes. I would need some concrete examples of doing very simple things that exhibits as many methods as possible.

Thank you.

like image 368
dader Avatar asked Oct 09 '12 00:10

dader


Video Answer


1 Answers

It has been released as is available on pecl, windows downloads on github pages ... git (source) if you can, more recent code ...

http://pthreads.org contains some more information, and checkout the examples folder too ...

If you're more specific in what you need to do I can provide a precise answer, feel free to contact me directly ...

Sorry about the lack of documentation, I am aggressively developing pthreads in what little time I have around work - it was written while I was on holiday from work and I am now back at work - the documentation will be updated as much as possible as soon as I find the time.

Threading is usually a complicated thing, but it needn't be ... ever seen a thread pool that is less than 100 lines ?? https://github.com/krakjoe/pthreads/blob/master/examples/Pooling.php ... there's one !!

You needn't know about conditions or mutex to operate threads in PHP, pthreads includes easy peasy everything ...

Jump on board, without question, I will perfect it ...

like image 134
Joe Watkins Avatar answered Oct 20 '22 00:10

Joe Watkins