Problem using libev c++ timer

Savio Sebastian savio_joysebastian at yahoo.com
Fri Dec 23 13:09:14 CET 2011


Hi all,
I am trying to use the timer in libev using c++
Here is my code

class Timer {
private:
    ev::timer stopTimer;
public:
    Timer() {
        stopTimer.set<Timer,&Timer::timeout_cb>(this);
        stopTimer.start(0.,5);
    }
    void timeout_cb(ev::timer &watcher, int revents) {
        cout << "TimeOut" << endl;
    }
};

int main(int argc,char **argv) {
    ev::default_loop loop;
    Timer time;
    loop.run(0);
    return 0;
}


Here my problem is the timeout call back function is getting called immediatly after the program execution begins instead of getting called after the timer has expired
can anyone please help me

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20111223/aeb84019/attachment.html>


More information about the libev mailing list