Adding Multi-Threading to PHP (Purely New Idea Try it)

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

Firstly please review my Spider Example .
Secondly in the code you saw :-
1. how the threads share data in apparently threading style
2. Another important thing how they talk Directly to the user through Ajax
3. To try this use AjT.Js version with the Spider example (didn't add it yet to Classes package)
To Everah:-
PHP does not support multi-threading
Yes , in a straight forward Manner but here we are using the Real Threading Support in The underlaying Web Server Apache2/IIS
No, the case isn't over since you made absolutely no sense with what you are saying here.
what's wrong in what i said ? i said :-
1. Threading abilities is an Enhancement just like Js
2. If users aren't enabling Js I'm going to use another script which is Sequential Not Threaded
why isn't this point over?
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

(rest of reply)
Where in your code is this happening?
Well...Yes it's in the code as they are separate scripts running so PHP engine provides all the stuff you mentioned
Are you seriously trying to imply that every browser supports Javascript at the present time
Yes . Except people sticking to versions from the past (old IE(<5) & old Netscape)
disabling Js is a completely separate issue as enabling it is just a double click matter (yet only 6% don't as stated in Prev. CoderGoblin comment)
o until you can force a browser to keep javscript enabled
As i said before Sequential scripts is their alternative

Waiting For your Reviews especially concerning Spider Example
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

So I plucked up the courage to download your code. I ran it on my own computer running Linux/Firefox (with AJAX enabled), seeing it fail on a permission denied error I chmod'd the entire directory to 0777. It ran without error, but all I got was a white screen with a form on it. Ok, so I then uploaded to my own server and ran it again: http://www.w3style.co.uk/~d11wtq/jsim/Jsim.php

White screen for me here again in Firefox. I haven't tried any other browser yet.

But what I do get to my complete horror even when the script has ended:

ls jsim (show files)

Code: Select all

AjT.js
Bag.php
Counter.php
Documentation(plain text written in Win notepad).txt
Downloader.php
Echoer.php
Jsim
Jsim.php
|Read=OFF|
|Read=OFF|Counter0=1|
|Read=OFF|Counter0=10|
|Read=OFF|Counter0=2|
|Read=OFF|Counter0=3|
|Read=OFF|Counter0=4|
|Read=OFF|Counter0=5|
|Read=OFF|Counter0=6|
|Read=OFF|Counter0=7|
|Read=OFF|Counter0=8|
|Read=OFF|Counter0=9|
|Read=ON|
|Read=ON|Counter0=1|
|Read=ON|Counter0=2|
|Read=ON|Counter0=3|
|Read=ON|Counter0=4|
|Read=ON|Counter0=5|
|Read=ON|Counter0=6|
|Read=ON|Counter0=7|
|Read=ON|Counter0=8|
|Read=ON|Counter0=9|
ThreadComHelper.php
ThreaderExample.php
Threader.JPG
Threader.php
Last edited by Chris Corbyn on Thu Sep 06, 2007 10:37 am, edited 1 time in total.
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

I for one do not trust code that:

1, Does not make use of a languages ability to assign meaningful names to variables / functions.
2, Has code laided out like: else{$Fdata=$data.$name."=".$value."|";}.

Anyway, what you are doing looks an awful lot like Ajax, and what your doing with files to pass data is just plain insane :?
Last edited by ody on Fri Sep 07, 2007 1:43 am, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I tried running your ThreaderExample.php, my CPU hit 100% and my web browser crashed (3 times).
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

ody wrote:Please stop coding, go back to learning the theory.
Please stop making these comments..
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

Well... The working version is here http://7zone1.110mb.com/Jsim.php
test it
the full project can be downloaded http://7zone1.110mb.com/asd.zip(all classes + example)
The problem is that i can't upload it SF so if any one uploaded it to their ftp i would appreciate it(As for my uploading problem i spitted to parts <1k and packed on server then decompressed which impossible on SF )
To d11wtq :-
well all problems you said happens because you didn't do what i said
White screen for me here again in Firefox. I haven't tried any other browser yet.
you used AjT.php version from classes not from Spider Example as i said
ls jsim (show files)
This because a small error in ThreaderComHelper.php which i fixed also(didn't affect results)
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

I just tried to test it with your links and it got a bunch of errors.
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

I tried running your ThreaderExample.php, my CPU hit 100% and my web browser crashed (3 times).
Why ? it works just good maybe because of Prev. problems
one last thing in Threader.php replace:-

Code: Select all

<script src="http://localhost/Spider/AjT.js"></script>
with

Code: Select all

<script src="AjT.js"></script>
it worked without changing in 110mb servers but Maybe why not
one last thing 110mb servers isn't 99.9% up as they say if loading takes too long be know that the server isn't responding now give it some time
To Begby:-
Try it now just an error name i changed accidentally try now :oops:
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

What's the matter. why didn't you comment now on the working version?
http://7zone1.110mb.com/Jsim.php
under the text there is the counter if you haven't noticed it
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

ASDen wrote:What's the matter. why didn't you comment now on the working version?
http://7zone1.110mb.com/Jsim.php
under the text there is the counter if you haven't noticed it
I get a counter, but the numbers are going on the wrong order. It keeps going back to 1 when it's half done.
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

what happened from crashing browsers & wrong order counting was errors i fixed
i tried to put fixed edition in 110mb in vain ... in SF The link is http://sourceforge.net/project/showfile ... _id=538090
with examples you will find testing results in FF, Opera, Safari, IE on WinXp
Ready to hear any question (Look at illustration Jpg in Documentation :D )
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I'm still curious as to whether you still consider this multi-threading.
Sounds to me like nothing more than asynchronous script calls.
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

:D :D :D My Uploading problem is Partaily solved :D :D :D
Now the Jsim link is : http://7zone1.110mb.com/Jsim.php

Testing Results on WinXp :-

1. in FireFox 2.0.0.6 :The counter is smooth as it's wanted
2. in IE 6,Opera 9.23,Safari 3.0.3 :After 10 seconds the number 10 appears (As they volatile Ajax and don't flag readystate 3)

Ready for any questions or challenging requests 8) 8)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

ASDen wrote:challenging requests
1. Get it to work without javascript.
2. Get it to work without a browser. (CLI Version)
Post Reply