ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.17 by root, Mon Nov 12 08:57:03 2007 UTC vs.
Revision 1.18 by root, Mon Nov 12 09:01:12 2007 UTC

48the beginning of 1970, details are complicated, don't ask). This type is 48the beginning of 1970, details are complicated, don't ask). This type is
49called C<ev_tstamp>, which is what you should use too. It usually aliases 49called C<ev_tstamp>, which is what you should use too. It usually aliases
50to the double type in C. 50to the double type in C.
51 51
52=head1 GLOBAL FUNCTIONS 52=head1 GLOBAL FUNCTIONS
53
54These functions can be called anytime, even before initialising the
55library in any way.
53 56
54=over 4 57=over 4
55 58
56=item ev_tstamp ev_time () 59=item ev_tstamp ev_time ()
57 60
560In this mode the values for C<interval> and C<at> are both being 563In this mode the values for C<interval> and C<at> are both being
561ignored. Instead, each time the periodic watcher gets scheduled, the 564ignored. Instead, each time the periodic watcher gets scheduled, the
562reschedule callback will be called with the watcher as first, and the 565reschedule callback will be called with the watcher as first, and the
563current time as second argument. 566current time as second argument.
564 567
565NOTE: I<This callback MUST NOT stop or destroy the periodic or any other 568NOTE: I<This callback MUST NOT stop or destroy any periodic watcher,
566periodic watcher, ever, or make any event loop modifications>. If you need 569ever, or make any event loop modifications>. If you need to stop it,
567to stop it, return C<now + 1e30> (or so, fudge fudge) and stop it afterwards. 570return C<now + 1e30> (or so, fudge fudge) and stop it afterwards (e.g. by
568 571starting a prepare watcher).
569Also, I<< this callback must always return a time that is later than the
570passed C<now> value >>. Not even C<now> itself will be ok.
571 572
572Its prototype is C<ev_tstamp (*reschedule_cb)(struct ev_periodic *w, 573Its prototype is C<ev_tstamp (*reschedule_cb)(struct ev_periodic *w,
573ev_tstamp now)>, e.g.: 574ev_tstamp now)>, e.g.:
574 575
575 static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now) 576 static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now)
579 580
580It must return the next time to trigger, based on the passed time value 581It must return the next time to trigger, based on the passed time value
581(that is, the lowest time value larger than to the second argument). It 582(that is, the lowest time value larger than to the second argument). It
582will usually be called just before the callback will be triggered, but 583will usually be called just before the callback will be triggered, but
583might be called at other times, too. 584might be called at other times, too.
585
586NOTE: I<< This callback must always return a time that is later than the
587passed C<now> value >>. Not even C<now> itself will do, it must be larger.
584 588
585This can be used to create very complex timers, such as a timer that 589This can be used to create very complex timers, such as a timer that
586triggers on each midnight, local time. To do this, you would calculate the 590triggers on each midnight, local time. To do this, you would calculate the
587next midnight after C<now> and return the timestamp value for this. How you do this 591next midnight after C<now> and return the timestamp value for this. How you do this
588is, again, up to you (but it is not trivial). 592is, again, up to you (but it is not trivial).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines