1<!-- Creator     : groff version 1.22.2 -->
2<!-- CreationDate: Sun Feb  5 16:09:43 2017 -->
3<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
4"http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<meta name="generator" content="groff -Thtml, see www.gnu.org">
8<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
9<meta name="Content-Style" content="text/css">
10<style type="text/css">
11       p       { margin-top: 0; margin-bottom: 0; vertical-align: top }
12       pre     { margin-top: 0; margin-bottom: 0; vertical-align: top }
13       table   { margin-top: 0; margin-bottom: 0; vertical-align: top }
14       h1      { text-align: center }
15</style>
16<title>mtcp_settimer</title>
17<link rel="stylesheet" href="./common.css">
18</head>
19<body>
20<div class="main">
21<h1 align="center">mtcp_settimer</h1>
22<!--
23<a href="#NAME">NAME</a><br>
24<a href="#SYNOPSIS">SYNOPSIS</a><br>
25<a href="#DESCRIPTION">DESCRIPTION</a><br>
26<a href="#RETURN VALUE">RETURN VALUE</a><br>
27<a href="#AUTHORS">AUTHORS</a><br>
28<a href="#SEE ALSO">SEE ALSO</a><br>
29<a href="#COLOPHON">COLOPHON</a><br>
30<hr>
31-->
32
33<h2>NAME
34<a name="NAME"></a>
35</h2>
36
37
38<p style="margin-left:11%; margin-top: 1em">mtcp_settimer
39&minus; register user&rsquo;s timer-based callback
40handler</p>
41
42<h2>SYNOPSIS
43<a name="SYNOPSIS"></a>
44</h2>
45
46
47<p style="margin-left:11%; margin-top: 1em"><b>#include
48&lt;mos_api.h&gt;</b></p>
49
50<p style="margin-left:11%; margin-top: 1em"><b>int
51mtcp_settimer(mctx_t</b> <i>mctx</i><b>, int</b>
52<i>id</i><b>, struct timeval *</b><i>timeout</i><b>,
53callback_t</b> <i>cb</i><b>);</b></p>
54
55<h2>DESCRIPTION
56<a name="DESCRIPTION"></a>
57</h2>
58
59
60
61<p style="margin-left:11%; margin-top: 1em"><b>mtcp_settimer</b>()
62can be used to register callback handler function, <i>cb
63,</i> that is invoked after a time interval of
64<i>timeout</i> microseconds. Note that this callback is a
65one time registration and <i>cb</i> (see
66<b>mtcp_register_callback</b>() for definition) is called
67only once when <i>timeout</i> period expires. The <i>id</i>
68argument is a unique identifier that is passed to <i>cb</i>
69as one of the function arguments.</p>
70
71
72<p style="margin-left:11%; margin-top: 1em"><b>mtcp_settimer</b>()
73call takes an additional argument named <i>mctx</i> that
74represents the per-core mTCP context in an application (see
75<b>mtcp_create_context()</b> for details).</p>
76
77<h2>RETURN VALUE
78<a name="RETURN VALUE"></a>
79</h2>
80
81
82<p style="margin-left:11%; margin-top: 1em">On success 0 is
83returned; -1 on failure.</p>
84
85<h2>AUTHORS
86<a name="AUTHORS"></a>
87</h2>
88
89
90<p style="margin-left:11%; margin-top: 1em">mOS development
91team &lt;[email protected]&gt;</p>
92
93<!----------------------------------------------------------->
94<h2>EXAMPLES
95<a name="EXAMPLES"></a>
96</h2>
97
98<p style="margin-left:11%; margin-top: 1em">
99  <a href="http://mos.kaist.edu/guide/programmer/05_api_example.html#registering-for-timer-events">
100	http://mos.kaist.edu/guide/programmer/05_api_example.html#registering-for-timer-events
101	</a>
102</p>
103<!----------------------------------------------------------->
104
105<h2>SEE ALSO
106<a name="SEE ALSO"></a>
107</h2>
108
109
110
111<p style="margin-left:11%; margin-top: 1em"><b>mtcp_register_callback</b>(),
112<b>mtcp_socket</b>(),</p>
113
114<h2>COLOPHON
115<a name="COLOPHON"></a>
116</h2>
117
118
119<p style="margin-left:11%; margin-top: 1em">This page is
120part of mOS release 0.3 <i>docs</i> section. A description
121of the project, and information about reporting bugs, can be
122found at http://mos.kaist.edu/.</p>
123<!-- <hr> -->
124<br>
125<div class="footer">
126  <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a>
127</div>
128</div>
129</body>
130</html>
131