File: on_time.html

package info (click to toggle)
liboop 1.0-8
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,664 kB
  • ctags: 492
  • sloc: sh: 7,970; ansic: 2,512; makefile: 136
file content (70 lines) | stat: -rw-r--r-- 2,657 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html><head>
<title>liboop: on_time(), cancel_time()</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head><body>

<h2>on_time(), cancel_time()</h2>

<pre>
#include &lt;oop.h&gt;
#include &lt;sys/time.h&gt;

/* <em>Zero time, for scheduling an event immediately.</em> */
static const struct timeval OOP_TIME_NOW = { 0, 0 };

/* <em>Callback function prototype.</em> */
typedef void *oop_call_time(oop_source *source,struct timeval tv,void *user);

/* <em>Register and unregister time-triggered event sinks.</em> */
void (*on_time)(oop_source *source,struct timeval tv,oop_call_time *call,void *user);
void (*cancel_time)(oop_source *source,struct timeval tv,oop_call_time *call,void *user);
</pre>

<h3>Arguments.</h3>

<dl>
<dt><b>oop_source *source</b>
<dd>The event source to register or unregister the event sink with.  This must 
be the same event source you got the function pointer from: 
"src-&gt;on_time(src,...);".<p>

<dt><b>struct timeval tv</b>
<dd>The time to wait for.  OOP_TIME_NOW (or any time in the past) will cause 
immediate scheduling.<p>

<dt><b>oop_call_time *call</b>
<dd>The callback function (event sink) to add (or remove).<p>

<dt><b>void *user</b>
<dd>User data passed through to the callback function.<p>
</dl>

<h3>Description.</h3>

Note that these are not global functions, but function pointers supplied
by the event source (in the <em>oop_source</em> structure) or by the user.

<dl>
<dt><b>on_time</b>
<dd>After this function is called, when the event loop is running and the 
time <em>tv</em> is reached (or immediately upon entry to the event loop, if 
the specified time occurs in the past), the event source will call the function
<em>call</em>, passing it a pointer to the event source, the scheduled time, 
and the same opaque <em>user</em> pointer passed to on_time.  This callback 
will only be called once.  Many callbacks may be registered for the same 
time.<p>

<dt><b>cancel_time</b>
<dd>Deactivate an event sink callback registered using on_time (above).  If the
passed <em>tv</em>, <em>call</em> and <em>user</em> match a previously 
registered callback, it will be removed; if they match more than one, one of
them will be removed; otherwise, no action is taken.<p>

<dt><b>oop_call_time</b>
<dd>Called when the event is triggered.  Performs a user_specific action.
Should return OOP_CONTINUE if the event loop should continue operating; any
other value (including OOP_HALT) will cause termination of the event loop.
</dl>

<hr><a href="ref.html">liboop reference</a></body></html>