| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2011-02-16 17:20 UTC] evert at rooftopsolutions dot nl
 Description:
------------
I'm not fully sure I got this right, but from my understanding of the event_timer_* the following script should display "foo".
Reproduce code:
---------------
$event = event_timer_new();
event_timer_set($event, function() {
    echo "foo\n";
});
$base = event_base_new();
event_timer_pending($event,1);
event_base_set($event, $base);
event_timer_add($event);
sleep(2);
echo "Starting main event loop\n";
event_base_loop($base);
echo "The end\n";
Expected result:
----------------
Starting main event loop
foo
The end
Actual result:
--------------
Starting main event loop
The end
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 05:00:01 2025 UTC | 
Actually it works just fine, you were just using a wrong func. Here is a working code: base = event_base_new(); $event = event_timer_new(); event_timer_set($event, function() { echo "foo\n"; }); event_base_set($event, $base); event_timer_add($event, 2000000 /* these are microseconds, yes */); echo "Starting main event loop\n"; event_base_loop($base); echo "The end\n"; Nevertheless, libevent extension does seem to lack some documentation. I'll add that into my TODO, but you're always welcome to help.