libnx/utimer_8h_source.html
2025-05-08 06:59:12 +00:00

167 lines
18 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libnx: include/switch/kernel/utimer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libnx<span id="projectnumber">&#160;v4.9.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_42bea3d40f1f1694e41a8f3166c98108.html">switch</a></li><li class="navelem"><a class="el" href="dir_36b4ff30955378a33ed199d75bfba1a9.html">kernel</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">utimer.h</div></div>
</div><!--header-->
<div class="contents">
<a href="utimer_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/**</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="comment"> * @file utimer.h</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="comment"> * @brief User-mode timer synchronization primitive.</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span><span class="comment"> * @author plutoo</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="comment"> * @copyright libnx Authors</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="comment"> */</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="preprocessor">#include &quot;<a class="code" href="wait_8h.html">wait.h</a>&quot;</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code hl_struct" href="structUTimer.html">UTimer</a> <a class="code hl_struct" href="structUTimer.html">UTimer</a>;</div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="comment"></span> </div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="comment">/// Valid types for a user-mode timer.</span></div>
<div class="foldopen" id="foldopen00013" data-start="{" data-end="};">
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"><a class="line" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939d"> 13</a></span><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">enum</span> {</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"><a class="line" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939daa93702ca4175addaf9d0e4568751f670"> 14</a></span> <a class="code hl_enumvalue" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939daa93702ca4175addaf9d0e4568751f670">TimerType_OneShot</a>, <span class="comment">///&lt; Timers of this kind fire once and then stop automatically.</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"><a class="line" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939dafa3d743de0084bf94270e7f81e2e4281"> 15</a></span> <a class="code hl_enumvalue" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939dafa3d743de0084bf94270e7f81e2e4281">TimerType_Repeating</a>, <span class="comment">///&lt; Timers of this kind fire periodically.</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span>} <a class="code hl_enumeration" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939d">TimerType</a>;</div>
</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span><span class="comment"></span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span><span class="comment">/// User-mode timer object.</span></div>
<div class="foldopen" id="foldopen00019" data-start="{" data-end="};">
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"><a class="line" href="structUTimer.html"> 19</a></span><span class="comment"></span><span class="keyword">struct </span><a class="code hl_struct" href="structUTimer.html">UTimer</a> {</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> <a class="code hl_struct" href="structWaitable.html">Waitable</a> waitable;</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> <a class="code hl_enumeration" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939d">TimerType</a> type : 8;</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> <span class="keywordtype">bool</span> started : 1;</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> <a class="code hl_typedef" href="types_8h.html#a3f7e2bcbb0b4c338f3c4f6c937cd4234">u64</a> next_tick;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> <a class="code hl_typedef" href="types_8h.html#a3f7e2bcbb0b4c338f3c4f6c937cd4234">u64</a> interval;</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span>};</div>
</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span><span class="comment"></span> </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span><span class="comment">/// Creates a waiter for a user-mode timer.</span></div>
<div class="foldopen" id="foldopen00028" data-start="{" data-end="}">
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="utimer_8h.html#a7e69adeeb3bcff5119c6d749a5bc4765"> 28</a></span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <a class="code hl_struct" href="structWaiter.html">Waiter</a> <a class="code hl_function" href="utimer_8h.html#a7e69adeeb3bcff5119c6d749a5bc4765">waiterForUTimer</a>(<a class="code hl_struct" href="structUTimer.html">UTimer</a>* t)</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span>{</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <a class="code hl_struct" href="structWaiter.html">Waiter</a> wait_obj;</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> wait_obj.type = WaiterType_Waitable;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> wait_obj.waitable = &amp;t-&gt;waitable;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <span class="keywordflow">return</span> wait_obj;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span>}</div>
</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="comment"></span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="comment">/**</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="comment"> * @brief Creates a user-mode timer.</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span><span class="comment"> * @param[out] t UTimer object.</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span><span class="comment"> * @param[in] interval Interval (in nanoseconds).</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="comment"> * @param[in] type Type of timer to create (see \ref TimerType).</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span><span class="comment"> * @note The timer is stopped when it is created. Use \ref utimerStart to start it.</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="comment"> * @note It is safe to wait on this timer with several threads simultaneously.</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span><span class="comment"> * @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees.</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span><span class="comment"> * @note For a repeating timer: If the timer triggers twice before you wait on it, you will only get one signal.</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span><span class="comment"> */</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="utimer_8h.html#a6fe2fd11c8a8306e5d2e102d9820e1b9"> 46</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="utimer_8h.html#a6fe2fd11c8a8306e5d2e102d9820e1b9">utimerCreate</a>(<a class="code hl_struct" href="structUTimer.html">UTimer</a>* t, <a class="code hl_typedef" href="types_8h.html#a3f7e2bcbb0b4c338f3c4f6c937cd4234">u64</a> interval, <a class="code hl_enumeration" href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939d">TimerType</a> type);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="comment"></span> </div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span><span class="comment">/**</span></div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span><span class="comment"> * @brief Starts the timer.</span></div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span><span class="comment"> * @param[in] t UTimer object.</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span><span class="comment"> */</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"><a class="line" href="utimer_8h.html#a44c6f3457b84802dfc9151d325fc1113"> 52</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="utimer_8h.html#a44c6f3457b84802dfc9151d325fc1113">utimerStart</a>(<a class="code hl_struct" href="structUTimer.html">UTimer</a>* t);</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span><span class="comment"></span> </div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span><span class="comment">/**</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span><span class="comment"> * @brief Stops the timer.</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span><span class="comment"> * @param[in] t UTimer object.</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span><span class="comment"> */</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="utimer_8h.html#abefdd14da8eb8f912407d2e4220aba82"> 58</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="utimer_8h.html#abefdd14da8eb8f912407d2e4220aba82">utimerStop</a>(<a class="code hl_struct" href="structUTimer.html">UTimer</a>* t);</div>
<div class="ttc" id="astructUTimer_html"><div class="ttname"><a href="structUTimer.html">UTimer</a></div><div class="ttdoc">User-mode timer object.</div><div class="ttdef"><b>Definition</b> utimer.h:19</div></div>
<div class="ttc" id="astructWaitable_html"><div class="ttname"><a href="structWaitable.html">Waitable</a></div><div class="ttdef"><b>Definition</b> wait.h:21</div></div>
<div class="ttc" id="astructWaiter_html"><div class="ttname"><a href="structWaiter.html">Waiter</a></div><div class="ttdoc">Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user...</div><div class="ttdef"><b>Definition</b> wait.h:36</div></div>
<div class="ttc" id="atypes_8h_html_a3f7e2bcbb0b4c338f3c4f6c937cd4234"><div class="ttname"><a href="types_8h.html#a3f7e2bcbb0b4c338f3c4f6c937cd4234">u64</a></div><div class="ttdeci">uint64_t u64</div><div class="ttdoc">64-bit unsigned integer.</div><div class="ttdef"><b>Definition</b> types.h:22</div></div>
<div class="ttc" id="autimer_8h_html_a44c6f3457b84802dfc9151d325fc1113"><div class="ttname"><a href="utimer_8h.html#a44c6f3457b84802dfc9151d325fc1113">utimerStart</a></div><div class="ttdeci">void utimerStart(UTimer *t)</div><div class="ttdoc">Starts the timer.</div></div>
<div class="ttc" id="autimer_8h_html_a6fe2fd11c8a8306e5d2e102d9820e1b9"><div class="ttname"><a href="utimer_8h.html#a6fe2fd11c8a8306e5d2e102d9820e1b9">utimerCreate</a></div><div class="ttdeci">void utimerCreate(UTimer *t, u64 interval, TimerType type)</div><div class="ttdoc">Creates a user-mode timer.</div></div>
<div class="ttc" id="autimer_8h_html_a7e69adeeb3bcff5119c6d749a5bc4765"><div class="ttname"><a href="utimer_8h.html#a7e69adeeb3bcff5119c6d749a5bc4765">waiterForUTimer</a></div><div class="ttdeci">static Waiter waiterForUTimer(UTimer *t)</div><div class="ttdoc">Creates a waiter for a user-mode timer.</div><div class="ttdef"><b>Definition</b> utimer.h:28</div></div>
<div class="ttc" id="autimer_8h_html_abefdd14da8eb8f912407d2e4220aba82"><div class="ttname"><a href="utimer_8h.html#abefdd14da8eb8f912407d2e4220aba82">utimerStop</a></div><div class="ttdeci">void utimerStop(UTimer *t)</div><div class="ttdoc">Stops the timer.</div></div>
<div class="ttc" id="autimer_8h_html_ad3a7c38fbde9814e427a75171fe8939d"><div class="ttname"><a href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939d">TimerType</a></div><div class="ttdeci">TimerType</div><div class="ttdoc">Valid types for a user-mode timer.</div><div class="ttdef"><b>Definition</b> utimer.h:13</div></div>
<div class="ttc" id="autimer_8h_html_ad3a7c38fbde9814e427a75171fe8939daa93702ca4175addaf9d0e4568751f670"><div class="ttname"><a href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939daa93702ca4175addaf9d0e4568751f670">TimerType_OneShot</a></div><div class="ttdeci">@ TimerType_OneShot</div><div class="ttdoc">Timers of this kind fire once and then stop automatically.</div><div class="ttdef"><b>Definition</b> utimer.h:14</div></div>
<div class="ttc" id="autimer_8h_html_ad3a7c38fbde9814e427a75171fe8939dafa3d743de0084bf94270e7f81e2e4281"><div class="ttname"><a href="utimer_8h.html#ad3a7c38fbde9814e427a75171fe8939dafa3d743de0084bf94270e7f81e2e4281">TimerType_Repeating</a></div><div class="ttdeci">@ TimerType_Repeating</div><div class="ttdoc">Timers of this kind fire periodically.</div><div class="ttdef"><b>Definition</b> utimer.h:15</div></div>
<div class="ttc" id="await_8h_html"><div class="ttname"><a href="wait_8h.html">wait.h</a></div><div class="ttdoc">User mode synchronization primitive waiting operations.</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>