php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59627 event_timer_* functions don't seem to work
Submitted: 2011-02-16 17:20 UTC Modified: 2013-01-31 19:01 UTC
From: evert at rooftopsolutions dot nl Assigned: tony2001 (profile)
Status: Not a bug Package: libevent (PECL)
PHP Version: 5.3.3 OS: OS/X
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: evert at rooftopsolutions dot nl
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-25 08:53 UTC] tony2001@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: tony2001
 [2013-01-31 19:00 UTC] tony2001@php.net
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.
 [2013-01-31 19:01 UTC] tony2001@php.net
.
 [2013-01-31 19:01 UTC] tony2001@php.net
-Status: Assigned +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC