123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|590|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Web Development -> PHP threading?

Sat, 11 Feb 2012, 04:21
Afr0
Does PHP have any support at all for concurrency?
Or: Is it safe to open a file with PHP, knowing it might be opened hundreds of times a second? Wouldn't that create an access conflict?
If I can safely open a file with PHP, it means I can have my patching script check if a manifest has a child that's newer than a client's version. Otherwise I'd have to let the client do it.
Also, can I send many files in succession with PHP, or would I have to compile all the manifests into a giant manifest?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sat, 11 Feb 2012, 05:51
Stealth
Does PHP have any support at all for concurrency?


Requests are concurrent with most server software like Apache. The language itself can't be concurrent without threading.

Or: Is it safe to open a file with PHP, knowing it might be opened hundreds of times a second? Wouldn't that create an access conflict?


It wont have access conflict. Linux will memory cache the file automatically. You may have a file stat occur each time. I would store this in memory if you plan on accessing it that often.

Also, can I send many files in succession with PHP, or would I have to compile all the manifests into a giant manifest?


You can send anything you want back. Browsers will expect one file but your own software can do anything you make it.

-=-=-
Quit posting and try Google.
Sat, 11 Feb 2012, 09:09
Afr0
Thanks!
I think I reached a compromise I can live with;



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sat, 11 Feb 2012, 11:40
JL235
Afr0 Does PHP have any support at all for concurrency?

No. There is no support for threads, or anything similar. It can be simulated creating a new PHP process which runs the PHP code you are running.

Stealth Requests are concurrent with most server software like Apache. The language itself can't be concurrent without threading.

Not true! Apache will run requests for a site in serial. If it didn't, then most small PHP websites would suffer database corruption, because most people don't use transactions.

I'm sorry to be nit-picking, but running PHP requests in parallel, and having support of concurrency, are not the same thing!
Sat, 11 Feb 2012, 12:56
Afr0
but running PHP requests in parallel, and having support of concurrency, are not the same thing!


No, they're just two means to achieve the same thing!

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sat, 11 Feb 2012, 16:32
Afr0
ARGH!
The script I made just keeps sending me an empty file, and I only discovered it as I was trying to make the client download said file. Something is obviously wrong, but the problem is I can't actually debug the script because neither echo() nor print() seems to work (except for when no argument is passed to the URL)!

Why?



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sat, 11 Feb 2012, 16:44
Afr0
Nevermind, I made it work.
Sun, 12 Feb 2012, 00:42
Stealth
Not true! Apache will run requests for a site in serial.


If this were true then a webpage that took 5 seconds to load would crash the server. Apache has no issue serving multiple PHP pages at the same time even if they have really long load times.

-=-=-
Quit posting and try Google.