As an update, I fixed the crashing bug, the usleep bug (I don't know if
it was really a bug, probably just a misinterpretation on my part), and
the hanging bug. I fixed thread joining. I updated the samples and I am
working on example05.php that will demo cURL!

Thanks to Tom R. who contacted me off the mailing list with a patch for
the crash that would have taken me forever to track down!

On 8/22/2010 11:12 PM, Alec wrote:
Hi guys, long time reader, 2nd time poster. I realize there is
much...bitterness about multithreading in PHP. I feel it is important,
but I know others don't. I just wanted to write and say that I have made
Moriyoshi Koizumi's php_threading (
http://github.com/moriyoshi/php-src/blob/PHP_5_3-threading/ext/threading/ )
available for Windows!

I converted all of the code to pthreads instead of GNU Pth so that
pthreads-win32 could be used on Windows. I am quite proud to say that
converted it all from Pth to pthreads by only reading the documentation
and never actually building it with GCC--and it worked the first time.
Well, not quite, but those were just dependency and other errors (like
that stupid 32 bit time thing)--all the pthreads stuff worked first time
(that is the first time I have said that about anything C related :D)! I
just converted it all in good ol' Notepad++ and then made VC2008 project.

My repo is at: http://github.com/alecgorge/php_threading

I push the compiled DLL so you can always find the latest compiled
version at:

If you are interested in a "stable" version I will post them at:

For those of you interested in helping, go ahead! The repo has
everything you need to build except for the Windows SDK and VC2008. It
has all the PHP headers, PHP libraries, pthreads-win32 headers and
pthreads-win32 libraries you need to compile yourself (in the deps folder).

Now for the bad part: it is really ****ing buggy. For example: most of
the samples work. Some never exit. Some crash. But overall it is
"stable" enough just to use for a quick personal project with PHP.

I think the biggest bug is that usleep breaks (whoops).

Here is my comments by sample (found in source/samples/)
01: Works well except for the crashing at the end.
02: Doesn't work at all. But I have never worked with sockets in PHP so
maybe someone wants to lend a hand?
03: Goes with example02. Doesn't work at all and I have no clue why.
04: Demos sending content to threads. It works except it never exits!

What I would like:
- Someone with real experience working with threads and C to give me a
hand tracking down some of the bugs. I am willing to fix things myself
but I am having trouble locating things!

- Linux people to help me out. I have no Linux box handy so tell me if
this build works with Linux. I tried to make sure I didn't break
anything by using conditional comments--and I think it works? (see:
for an example)

- Linux people to give me build instructions. You can see Moriyoshi's
original instructions at

Sorry for the wall of text, I just had a very productive 12 hours of
coding and wanted to tell the world :D


Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupphp-internals @
postedAug 23, '10 at 3:12a
activeAug 24, '10 at 11:33p

1 user in discussion

Alec: 3 posts



site design / logo © 2022 Grokbase