Re: [PHP] Threading objects
As i rember apache can not handle a threading php ... if you whant threads you need to run php from command prompt in a linux/unix enviroment(windows dosen't support threads i I'm not wrong).Look for a threads project in PEAR(http://pear.php.net/). Hope it helps, Best regards, Alex. Is it possible to some how thread a php script threw apache. There has to be something you can do, it seems there is always something you can do :) What I want is the following. I administer a mailing list that has a few hundred thousand subscribed recipients. I've written a script that runs threw the DB and validates the email address. First by format then by connecting to the mail server. This script takes way to long to run as it has to do one at a time. I want to some how thread this so it can be validating multiple emails at a time. Please excuse my ignorance on the subject my web programming experience is rather limited. Thanks Kris - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Kris [EMAIL PROTECTED] Cc: W. Enserink [EMAIL PROTECTED]; PHP List [EMAIL PROTECTED] Sent: Thursday, March 13, 2003 1:04 AM Subject: Re: [PHP] Threading objects All I'm really asking is how do you initiate threading with PHP? A small example would be nice You don't. This is a web scripting language, not Java. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
i'm not sure what you want. But you have created objects here in $a,$b and $c. If you want to order them in a special way you have to write the functionality of course. I think you have to do this before the object is created because you define the variables 10,5,1 before the objects are created. Once the objects are created they themselves don't know nothing form each other. So th eparent object has to control this, or in your case a 'parent piece of script'. You can use $a,$b,and $c as regular,ordinary variables. further on. hope it helped, Wilbert - Original Message - From: Kris [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 12:18 PM Subject: [PHP] Threading objects I want to be able to thread objects. I'm not really sure at all where to start. but I want a script where multiple objects are being processed at the same time. I have an example php script ? $a = new sleeper(); $b = new sleeper(); $c = new sleeper(); $a-sleepFor(10); $b-sleepFor(5); $c-sleepFor(1); class sleeper { function sleepFor($num) { sleep($num); echo sorry I was a sleep for $num \r\n; } } ? I want so object $c would print then object $b then object $a as the sleeping time is less and less. Does that make sense? Please ask if you don't understand Thanks for any help you can offer what so ever. Kris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl [EMAIL PROTECTED] - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
Hi Wilbert Thanks for responding. However I am completely aware of how objects work as I come from a Java back ground. If you are familiar with Java at all I'm looking for something like the PipedOutputStream, PipedInputStream and Thread classes I want the processes objects to be threaded, therefore processing simultaneously. This would mean $c would print first as it slept for the least amount of time. All I'm really asking is how do you initiate threading with PHP? A small example would be nice Regards Kris - Original Message - From: W. Enserink [EMAIL PROTECTED] To: Kris [EMAIL PROTECTED]; PHP List [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 9:29 PM Subject: Re: [PHP] Threading objects i'm not sure what you want. But you have created objects here in $a,$b and $c. If you want to order them in a special way you have to write the functionality of course. I think you have to do this before the object is created because you define the variables 10,5,1 before the objects are created. Once the objects are created they themselves don't know nothing form each other. So th eparent object has to control this, or in your case a 'parent piece of script'. You can use $a,$b,and $c as regular,ordinary variables. further on. hope it helped, Wilbert - Original Message - From: Kris [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 12:18 PM Subject: [PHP] Threading objects I want to be able to thread objects. I'm not really sure at all where to start. but I want a script where multiple objects are being processed at the same time. I have an example php script ? $a = new sleeper(); $b = new sleeper(); $c = new sleeper(); $a-sleepFor(10); $b-sleepFor(5); $c-sleepFor(1); class sleeper { function sleepFor($num) { sleep($num); echo sorry I was a sleep for $num \r\n; } } ? I want so object $c would print then object $b then object $a as the sleeping time is less and less. Does that make sense? Please ask if you don't understand Thanks for any help you can offer what so ever. Kris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl [EMAIL PROTECTED] - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
I think that he wants a function that acts like steTimeout(..) in JavaScript ex: code setTimeout('alert('tst2')',5000); setTimeout('alert('tst1')',4000); /code When you exec this code in js the first alert that is executed is tst1 and then tst2. I don't know if you can do this in php without using threads. I am not sure that this is the only function he whants to use this way, but if I am not wrong threading dose the job very well. btw what is the status of that project? Is it functional yet? I havent read the php-dev discutions on this yet. On Wed, 2003-03-12 at 13:29, W. Enserink wrote: i'm not sure what you want. But you have created objects here in $a,$b and $c. If you want to order them in a special way you have to write the functionality of course. I think you have to do this before the object is created because you define the variables 10,5,1 before the objects are created. Once the objects are created they themselves don't know nothing form each other. So th eparent object has to control this, or in your case a 'parent piece of script'. You can use $a,$b,and $c as regular,ordinary variables. further on. hope it helped, Wilbert - Original Message - From: Kris [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 12:18 PM Subject: [PHP] Threading objects I want to be able to thread objects. I'm not really sure at all where to start. but I want a script where multiple objects are being processed at the same time. I have an example php script ? $a = new sleeper(); $b = new sleeper(); $c = new sleeper(); $a-sleepFor(10); $b-sleepFor(5); $c-sleepFor(1); class sleeper { function sleepFor($num) { sleep($num); echo sorry I was a sleep for $num \r\n; } } ? I want so object $c would print then object $b then object $a as the sleeping time is less and less. Does that make sense? Please ask if you don't understand Thanks for any help you can offer what so ever. Kris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl [EMAIL PROTECTED] - -- Mincu Alexandru intelinet.ro Tel:+4 0745 369719 +4 021 3140021 www.intelinet.ro[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
Kris wrote: I want to be able to thread objects. I'm not really sure at all where to start. but I want a script where multiple objects are being processed at the same time. I have an example php script ? $a = new sleeper(); $b = new sleeper(); $c = new sleeper(); $a-sleepFor(10); $b-sleepFor(5); $c-sleepFor(1); class sleeper { function sleepFor($num) { sleep($num); echo sorry I was a sleep for $num \r\n; } } ? I want so object $c would print then object $b then object $a as the sleeping time is less and less. Does that make sense? Please ask if you don't understand Thanks for any help you can offer what so ever. Kris Hi, generally, multithreading (using system threads) within PHP is impossible, AFAIK. Of course running (apache) processes can communicate via shm but it is not multithreading. Your code will be executed sequentially as written. One sleep will start after another ends. There is not known, to me, solution, sorry :(; -- Mirek Novak Anima Publishers, s.r.o. Prilucka 360, Zlin 760 01 Czech Republic tel/fax: +420577219132 GSM:+420603807837 jabber:[EMAIL PROTECTED] ICQ:119499448 AUTO.CZ http://www.auto.cz NEWS.AUTO.CZ http://news.auto.cz FORMULE1.CZ http://www.formule1.cz -- Mirek Novak Anima Publishers, s.r.o. Prilucka 360, Zlin 760 01 Czech Republic tel/fax: +420577219132 GSM:+420603807837 jabber:[EMAIL PROTECTED] ICQ:119499448 AUTO.CZ http://www.auto.cz NEWS.AUTO.CZ http://news.auto.cz FORMULE1.CZ http://www.formule1.cz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
All I'm really asking is how do you initiate threading with PHP? A small example would be nice You don't. This is a web scripting language, not Java. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
Is it possible to some how thread a php script threw apache. There has to be something you can do, it seems there is always something you can do :) What I want is the following. I administer a mailing list that has a few hundred thousand subscribed recipients. I've written a script that runs threw the DB and validates the email address. First by format then by connecting to the mail server. This script takes way to long to run as it has to do one at a time. I want to some how thread this so it can be validating multiple emails at a time. Please excuse my ignorance on the subject my web programming experience is rather limited. Thanks Kris - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Kris [EMAIL PROTECTED] Cc: W. Enserink [EMAIL PROTECTED]; PHP List [EMAIL PROTECTED] Sent: Thursday, March 13, 2003 1:04 AM Subject: Re: [PHP] Threading objects All I'm really asking is how do you initiate threading with PHP? A small example would be nice You don't. This is a web scripting language, not Java. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
So your problem has nothing to do with threading. What you need an an asynchronous way to connect to multiple sockets and deal with responses as they become available. See php.net/socket_select -Rasmus On Thu, 13 Mar 2003, Kris wrote: Is it possible to some how thread a php script threw apache. There has to be something you can do, it seems there is always something you can do :) What I want is the following. I administer a mailing list that has a few hundred thousand subscribed recipients. I've written a script that runs threw the DB and validates the email address. First by format then by connecting to the mail server. This script takes way to long to run as it has to do one at a time. I want to some how thread this so it can be validating multiple emails at a time. Please excuse my ignorance on the subject my web programming experience is rather limited. Thanks Kris - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Kris [EMAIL PROTECTED] Cc: W. Enserink [EMAIL PROTECTED]; PHP List [EMAIL PROTECTED] Sent: Thursday, March 13, 2003 1:04 AM Subject: Re: [PHP] Threading objects All I'm really asking is how do you initiate threading with PHP? A small example would be nice You don't. This is a web scripting language, not Java. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Threading objects
At 23:23 12.03.2003, Kris said: [snip] Is it possible to some how thread a php script threw apache. There has to be something you can do, it seems there is always something you can do :) What I want is the following. I administer a mailing list that has a few hundred thousand subscribed recipients. I've written a script that runs threw the DB and validates the email address. First by format then by connecting to the mail server. This script takes way to long to run as it has to do one at a time. I want to some how thread this so it can be validating multiple emails at a time. Please excuse my ignorance on the subject my web programming experience is rather limited. [snip] Well, web is (or at least should be) kind of real-time, thus you should try to postpone lengthy actions. What I'd try (and I already did such stuff with success) is to just create some DB entries, in your case this would mean to add a validation request entry to a database, or even simply a todo file. Another process, most certainly run by a cron job, would then read the DB (or the toto file) and perform actions necessary. When done it would update some kind of status flag. On your website yo could display something like 187322 addresses scheduled for validation - 123499 to go, or something like that, just by reading the status data updated by the cron job. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php