Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 magnus 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
<html><head>
3
<title>liboop: on_time(), cancel_time()</title>
4
<link rel="stylesheet" type="text/css" href="style.css">
5
</head><body>
6
 
7
<h2>on_time(), cancel_time()</h2>
8
 
9
<pre>
10
#include &lt;oop.h&gt;
11
#include &lt;sys/time.h&gt;
12
 
13
/* <em>Zero time, for scheduling an event immediately.</em> */
14
static const struct timeval OOP_TIME_NOW = { 0, 0 };
15
 
16
/* <em>Callback function prototype.</em> */
17
typedef void *oop_call_time(oop_source *source,struct timeval tv,void *user);
18
 
19
/* <em>Register and unregister time-triggered event sinks.</em> */
20
void (*on_time)(oop_source *source,struct timeval tv,oop_call_time *call,void *user);
21
void (*cancel_time)(oop_source *source,struct timeval tv,oop_call_time *call,void *user);
22
</pre>
23
 
24
<h3>Arguments.</h3>
25
 
26
<dl>
27
<dt><b>oop_source *source</b>
28
<dd>The event source to register or unregister the event sink with.  This must
29
be the same event source you got the function pointer from:
30
"src-&gt;on_time(src,...);".<p>
31
 
32
<dt><b>struct timeval tv</b>
33
<dd>The time to wait for.  OOP_TIME_NOW (or any time in the past) will cause
34
immediate scheduling.<p>
35
 
36
<dt><b>oop_call_time *call</b>
37
<dd>The callback function (event sink) to add (or remove).<p>
38
 
39
<dt><b>void *user</b>
40
<dd>User data passed through to the callback function.<p>
41
</dl>
42
 
43
<h3>Description.</h3>
44
 
45
Note that these are not global functions, but function pointers supplied
46
by the event source (in the <em>oop_source</em> structure) or by the user.
47
 
48
<dl>
49
<dt><b>on_time</b>
50
<dd>After this function is called, when the event loop is running and the
51
time <em>tv</em> is reached (or immediately upon entry to the event loop, if
52
the specified time occurs in the past), the event source will call the function
53
<em>call</em>, passing it a pointer to the event source, the scheduled time,
54
and the same opaque <em>user</em> pointer passed to on_time.  This callback
55
will only be called once.  Many callbacks may be registered for the same
56
time.<p>
57
 
58
<dt><b>cancel_time</b>
59
<dd>Deactivate an event sink callback registered using on_time (above).  If the
60
passed <em>tv</em>, <em>call</em> and <em>user</em> match a previously
61
registered callback, it will be removed; if they match more than one, one of
62
them will be removed; otherwise, no action is taken.<p>
63
 
64
<dt><b>oop_call_time</b>
65
<dd>Called when the event is triggered.  Performs a user_specific action.
66
Should return OOP_CONTINUE if the event loop should continue operating; any
67
other value (including OOP_HALT) will cause termination of the event loop.
68
</dl>
69
 
70
<hr><a href="ref">liboop reference</a></body></html>