Re: parallell execution

From: Date: Tue, 29 Aug 2000 12:09:30 +0000
Subject: Re: parallell execution
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-31051@lists.php.net to get a copy of this message
Stig Venaas wrote: > > Just a thought I would like to share. > > I have a case where I want to search several LDAP servers, and then > present the combined data, It makes a big difference to search in > parallell. > > Another case is where I take some data from an LDAP server and other > data from a database and want to do it in parallell. > > It would be neat if I could specify when I'm calling a function that > I want it to be "in the background" (a separate thread). Something > like: > > $a = f(x); > > echo 1; > echo 2; > echo 3; > echo $a; > > Where 1 2 3 is printed while f executes, and then wait for f to > finish when $a is referenced. Of course f might interact with > other stuff so it might get hairy. > > Another possibility which might be easier is something like: > > $a = &(7) f(x); > echo 1; > echo 2; > echo 3; > wait (7); > echo $a; > > Am I crazy, has anyone been thinking of things like these? What kind > of thread support has (will have) Zend? No thread support, but I managed to convince Zeev and Andi to give us ticks support at the PDM in January. I just fixed some bugs in it, so it's actually usable now. A "tick" is a callback from the parser every N statements, where N is defined in a "declare" block: declare(ticks = 4) { // for every four statements in here, a tick is called. // the declare itself seems to count as one statement. 1;1;1;; // tick 1;1;1;1; // tick } There's a C API for registering your own tick callbacks. Example: void my_tick_callback(int count) { php_printf("[tick=%d]", count); } PHP_MINFO_FUNCTION(myext) { php_add_tick_function(my_tick_callback); } The PHP code above would then display: [tick=4][tick=4] I want this to implement "backgrounded" asynchronous I/O, which I guess is more or less what you need it for as well? - Stig

« previous php.dev (#31051) next »