On Fri, Dec 23, 2011 at 05:39:14PM +0530, Savio Sebastian
<[email protected]> wrote:
> 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
First of all, you are using undocumented functionality, which is not
supported (ev::default_loop) nor maintained.
Second, you initialise the timer to be invoked "0." seconds after start, and
then every 5 seconds afterwards, so that seems to match what you are getting.
Does it work like you expect if you swap the arguments of start to "(5, 0)"?
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / [email protected]
-=====/_/_//_/\_,_/ /_/\_\
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev