SoylentNews
SoylentNews is people
https://soylentnews.org/

Title    PHP - Thread Carefully
Date    Wednesday November 25 2015, @10:31AM
Author    cmn32480
Topic   
from the get-this-all-sewn-up dept.
https://soylentnews.org/article.pl?sid=15/11/24/220228

Phoenix666 writes:

As far as I can remember, PHP has always had a terrible reputation at handling very heavy (or asynchronous) tasks. For a long while if you wanted to parallelize long tasks you had to resort to forking through pcntl_fork which had its own issues, and you couldn't really handle the results of those tasks properly, etc.

As such, a habit has kind of developed where we go straight for more intricate solutions such as queuing (which just delays your task if anything), React PHP, or even using another language altogether. But PHP can do threading, and more importantly it's a lot easier than you probably think.

In this article I'm going to dive into the pthreads extension (short for POSIX Threads). It has been around for a while (since 2012) but I feel like too many people forget it exists or assume it is going to be painful to use – mostly because the official documentation is rather slim about it.


Original Submission

Links

  1. "Phoenix666" - https://soylentnews.org/~Phoenix666/
  2. "But PHP can do threading, and more importantly it's a lot easier than you probably think" - http://blog.madewithlove.be/post/thread-carefully/
  3. "Original Submission" - https://soylentnews.org/submit.pl?op=viewsub&subid=10651

© Copyright 2024 - SoylentNews, All Rights Reserved

printed from SoylentNews, PHP - Thread Carefully on 2024-04-27 18:46:42