| |
| |
| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| |
| |
| |
| <title>Event Queues — Apache Mynewt latest documentation</title> |
| |
| |
| |
| |
| <link rel="shortcut icon" href="../../../_static/mynewt-logo-only-newt32x32.png"/> |
| |
| |
| |
| |
| <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> |
| |
| |
| <link rel="stylesheet" href="../../../_static/css/sphinx_theme.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../../../_static/css/bootstrap-3.0.3.min.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../../../_static/css/v2.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../../../_static/css/restructuredtext.css" type="text/css" /> |
| |
| |
| |
| |
| <link rel="stylesheet" href="../../../_static/css/overrides.css" type="text/css" /> |
| <link rel="index" title="Index" |
| href="../../../genindex.html"/> |
| <link rel="search" title="Search" href="../../../search.html"/> |
| <link rel="top" title="Apache Mynewt latest documentation" href="../../../index.html"/> |
| <link rel="up" title="Apache Mynewt Operating System Kernel" href="../mynewt_os.html"/> |
| <link rel="next" title="Callout" href="../callout/callout.html"/> |
| <link rel="prev" title="Semaphore" href="../semaphore/semaphore.html"/> |
| |
| |
| <script src="../../../_static/js/modernizr.min.js"></script> |
| |
| |
| <script> |
| (function(i, s, o, g, r, a, m) { |
| i["GoogleAnalyticsObject"] = r; |
| (i[r] = |
| i[r] || |
| function() { |
| (i[r].q = i[r].q || []).push(arguments); |
| }), |
| (i[r].l = 1 * new Date()); |
| (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]); |
| a.async = 1; |
| a.src = g; |
| m.parentNode.insertBefore(a, m); |
| })(window, document, "script", "//www.google-analytics.com/analytics.js", "ga"); |
| |
| ga("create", "UA-72162311-1", "auto"); |
| ga("send", "pageview"); |
| </script> |
| |
| |
| </head> |
| |
| <body class="not-front page-documentation" role="document" > |
| <div id="wrapper"> |
| <div class="container"> |
| <div id="banner" class="row v2-main-banner"> |
| <a class="logo-cell" href="/"> |
| <img class="logo" src="../../../_static/img/logo.png"> |
| </a> |
| <div class="tagline-cell"> |
| <h4 class="tagline">An OS to build, deploy and securely manage billions of devices</h4> |
| </div> |
| <div class="news-cell"> |
| <div class="well"> |
| <h4>Latest News:</h4> <a href="/download">Apache Mynewt 1.12.0, Apache NimBLE 1.7.0 </a> released April 4, 2024) |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| <header> |
| <nav id="navbar" class="navbar navbar-inverse" role="navigation"> |
| <div class="container"> |
| <!-- Collapsed navigation --> |
| <div class="navbar-header"> |
| <!-- Expander button --> |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| |
| </div> |
| |
| <!-- Expanded navigation --> |
| <div class="navbar-collapse collapse"> |
| <!-- Main navigation --> |
| <ul class="nav navbar-nav navbar-right"> |
| <li> |
| <a href="/"><i class="fa fa-home" style="font-size: larger;"></i></a> |
| </li> |
| <li class="important"> |
| <a href="/quick-start/">Quick Start</a> |
| </li> |
| <li> |
| <a href="/about/">About</a> |
| </li> |
| <li> |
| <a href="/talks/">Talks</a> |
| </li> |
| <li class="active"> |
| <a href="/documentation/">Documentation</a> |
| </li> |
| <li> |
| <a href="/download/">Download</a> |
| </li> |
| <li> |
| <a href="/community/">Community</a> |
| </li> |
| <li> |
| <a href="/events/">Events</a> |
| </li> |
| </ul> |
| |
| <!-- Search, Navigation and Repo links --> |
| <ul class="nav navbar-nav navbar-right"> |
| |
| </ul> |
| </div> |
| </div> |
| </nav> |
| </header> |
| <!-- STARTS MAIN CONTENT --> |
| <div id="main-content"> |
| |
| |
| |
| |
| |
| |
| <div id="breadcrumb"> |
| <div class="container"> |
| <a href="/documentation/">Docs</a> / |
| |
| <a href="../../os_user_guide.html">OS User Guide</a> / |
| |
| <a href="../mynewt_os.html">Apache Mynewt Operating System Kernel</a> / |
| |
| Event Queues |
| |
| <div class="sourcelink"> |
| <a href="https://github.com/apache/mynewt-core/edit/master/docs/os/core_os/event_queue/event_queue.rst" class="icon icon-github" |
| rel="nofollow"> Edit on GitHub</a> |
| </div> |
| </div> |
| </div> |
| <!-- STARTS CONTAINER --> |
| <div class="container"> |
| <!-- STARTS .content --> |
| <div id="content" class="row"> |
| |
| <!-- STARTS .container-sidebar --> |
| <div class="container-sidebar col-xs-12 col-sm-3"> |
| <div id="docSidebar" class="sticky-container"> |
| <div role="search" class="sphinx-search"> |
| <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search documentation" class="search-documentation" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| <!-- Note: only works when deployed --> |
| <select class="form-control" onchange="if (this.value) window.location.href=this.value"> |
| <option value="/latest" selected> |
| Version: latest |
| </option> |
| <option value="/v1_12_0" > |
| Version: 1.12.0 |
| </option> |
| <option value="/v1_11_0" > |
| Version: 1.11.0 |
| </option> |
| <option value="/v1_10_0" > |
| Version: 1.10.0 |
| </option> |
| <option value="/v1_9_0" > |
| Version: 1.9.0 |
| </option> |
| <option value="/v1_8_0" > |
| Version: 1.8.0 |
| </option> |
| <option value="/v1_7_0" > |
| Version: 1.7.0 |
| </option> |
| <option value="/v1_6_0" > |
| Version: 1.6.0 |
| </option> |
| <option value="/v1_5_0" > |
| Version: 1.5.0 |
| </option> |
| <option value="/v1_4_0" selected="selected" > |
| Version: 1.4.0 |
| </option> |
| <option value="/v1_3_0/os/introduction" > |
| Version: 1.3.0 |
| </option> |
| <option value="/v1_2_0/os/introduction" > |
| Version: 1.2.0 |
| </option> |
| <option value="/v1_1_0/os/introduction" > |
| Version: 1.1.0 |
| </option> |
| <option value="/v1_0_0/os/introduction" > |
| Version: 1.0.0 |
| </option> |
| <option value="/v0_9_0/os/introduction" > |
| Version: 0.9.0 |
| </option> |
| </select> |
| <div class="region region-sidebar"> |
| <div class="docs-menu"> |
| |
| |
| |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../../../index.html">Introduction</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../get_started/index.html">Setup & Get Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../concepts.html">Concepts</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../tutorials/tutorials.html">Tutorials</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../external_links.html">Third-party Resources</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="../../os_user_guide.html">OS User Guide</a><ul class="current"> |
| <li class="toctree-l2 current"><a class="reference internal" href="../mynewt_os.html">Kernel</a><ul class="current"> |
| <li class="toctree-l3"><a class="reference internal" href="../context_switch/context_switch.html">Scheduler</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../task/task.html">Task</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mutex/mutex.html">Mutex</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../semaphore/semaphore.html">Semaphore</a></li> |
| <li class="toctree-l3 current"><a class="current reference internal" href="#">Event Queues</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../callout/callout.html">Callout</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../heap/heap.html">Heap</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../memory_pool/memory_pool.html">Memory Pools</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mbuf/mbuf.html">Mbufs</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../cputime/os_cputime.html">CPU Time</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../time/os_time.html">OS Time</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../sanity/sanity.html">Sanity</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/system_modules.html">System</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/hal/hal.html">Hardware Abstraction</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/bootloader/bootloader.html">Secure Bootloader</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/split/split.html">Split Images</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../porting/port_os.html">Porting Guide</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/sysinitconfig/sysinitconfig.html">Compile-Time Configuration</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/console/console.html">Console</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/shell/shell.html">Shell</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/testutil/testutil.html">Test Utilities</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/json/json.html">JSON</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/stats/stats.html">Statistics</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../modules/logs/logs.html">Logs</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../network/index.html">BLE User Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../newt/index.html">Newt Tool Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../newtmgr/index.html">Newt Manager Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../mynewt_faq/index.html">Mynewt FAQ</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../misc/index.html">Appendix</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| </div> |
| </div> |
| <!-- ENDS STICKY CONTAINER --> |
| </div> |
| <!-- ENDS .container-sidebar --> |
| |
| <div class="col-xs-12 col-sm-9"> |
| |
| <div class="alert alert-warning"> |
| <p> |
| Version 1.4.0 is not the most recent version of the |
| Apache Mynewt documentation. Click <a href="/latest">here</a> to |
| read the latest version. |
| </p> |
| </div> |
| |
| |
| |
| <div class=""> |
| <div class="rst-content"> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="event-queues"> |
| <h1>Event Queues<a class="headerlink" href="#event-queues" title="Permalink to this headline">¶</a></h1> |
| <p>An event queue allows a task to serialize incoming events and simplify |
| event processing. Events are stored in a queue and a task removes and |
| processes an event from the queue. An event is processed in the context |
| of this task. Events may be generated by OS callouts, interrupt handlers, |
| and other tasks.</p> |
| <div class="section" id="description"> |
| <h2>Description<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2> |
| <p>Mynewt’s event queue model uses callback functions to process events. |
| Each event is associated with a callback function that is called to |
| process the event. This model enables a library package, that uses |
| events in its implementation but does not have real-time timing |
| requirements, to use an application event queue instead of creating a |
| dedicated event queue and task to process its events. The callback |
| function executes in the context of the task that the application |
| creates to manage the event queue. This model reduces an application’s |
| memory requirement because memory must be allocated for the task’s stack |
| when a task is created. A package that has real-time timing requirements |
| and must run at a specific task priority should create a dedicated event |
| queue and task to process its events.</p> |
| <p>In the Mynewt model, a package defines its events and implements the |
| callback functions for the events. A package that does not have |
| real-time timing requirements should use Mynewt’s default event queue |
| for its events. The callback function for an event from the Mynewt |
| default event queue is executed in the context of the application main |
| task. A package can, optionally, export a function that allows an |
| application to specify the event queue for the package to use. The |
| application task handler that manages the event queue simply pulls events |
| from the event queue and executes the event’s callback function in its context.</p> |
| <p>A common way that Mynewt applications or packages process events from an |
| event queue is to have a task that executes in an infinite loop and |
| calls the <a class="reference internal" href="#c.os_eventq_get" title="os_eventq_get"><code class="xref c c-func docutils literal notranslate"><span class="pre">os_eventq_get()</span></code></a> function to dequeue and return the event |
| from the head of the event queue. The task then calls the event callback |
| function to process the event. The <a class="reference internal" href="#c.os_eventq_get" title="os_eventq_get"><code class="xref c c-func docutils literal notranslate"><span class="pre">os_eventq_get()</span></code></a> function puts the |
| task in to the <code class="docutils literal notranslate"><span class="pre">sleeping</span></code> state when there are no events on the queue. |
| (See <a class="reference internal" href="../context_switch/context_switch.html"><span class="doc">Scheduler</span></a> for more |
| information on task execution states.) Other tasks (or interrupts) call |
| the <a class="reference internal" href="#c.os_eventq_put" title="os_eventq_put"><code class="xref c c-func docutils literal notranslate"><span class="pre">os_eventq_put()</span></code></a> function to add an event to the queue. The |
| <a class="reference internal" href="#c.os_eventq_put" title="os_eventq_put"><code class="xref c c-func docutils literal notranslate"><span class="pre">os_eventq_put()</span></code></a> function determines whether a task is blocked |
| waiting for an event on the queue and puts the task into the |
| <code class="docutils literal notranslate"><span class="pre">ready-to-run</span></code> state.</p> |
| <p>A task can use the <a class="reference internal" href="#c.os_eventq_run" title="os_eventq_run"><code class="xref c c-func docutils literal notranslate"><span class="pre">os_eventq_run()</span></code></a> wrapper function that calls the |
| <a class="reference internal" href="#c.os_eventq_get" title="os_eventq_get"><code class="xref c c-func docutils literal notranslate"><span class="pre">os_eventq_get()</span></code></a> function to dequeue an event from the queue and then |
| calls the event callback function to process the event. |
| Note:</p> |
| <ul class="simple"> |
| <li><p>Only one task should consume or block waiting for events from an |
| event queue.</p></li> |
| <li><p>The OS callout subsystem uses events for timer expiration notification.</p></li> |
| </ul> |
| </div> |
| <div class="section" id="example"> |
| <h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> |
| <p>Here is an example of using an event from the BLE host:</p> |
| <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">static</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="nf">ble_hs_event_tx_notify</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">os_event</span><span class="w"> </span><span class="o">*</span><span class="n">ev</span><span class="p">);</span> |
| |
| <span class="cm">/** OS event - triggers tx of pending notifications and indications. */</span> |
| <span class="k">static</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">os_event</span><span class="w"> </span><span class="n">ble_hs_ev_tx_notifications</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> |
| <span class="w"> </span><span class="p">.</span><span class="n">ev_cb</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ble_hs_event_tx_notify</span><span class="p">,</span> |
| <span class="p">};</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="api"> |
| <h2>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h2> |
| <dl class="c type"> |
| <dt id="c.os_event_fn"> |
| <span class="target" id="group___o_s_event_1ga6e572d40b307b9f40bec72281548b63e"></span><em class="property"><span class="pre">typedef</span> </em><span class="pre">void</span> <code class="sig-name descname"><span class="pre">os_event_fn</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_event" title="os_event"><span class="pre">os_event</span></a> <span class="pre">*</span><em><span class="pre">ev</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.os_event_fn" title="Permalink to this definition">¶</a><br /></dt> |
| <dd></dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_init"> |
| <span class="target" id="group___o_s_event_1ga12330bd028b5efdb00b96f8d85ad576b"></span><span class="pre">void</span> <code class="sig-name descname"><span class="pre">os_eventq_init</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a><span class="pre">*</span><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_init" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Initialize the event queue. </p> |
| <p><dl class="simple"> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: The event queue to initialize </p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_inited"> |
| <span class="target" id="group___o_s_event_1ga21fb29b6ce469a93d87eacc2c64f7bca"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">os_eventq_inited</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">const</span></em> <em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a> <span class="pre">*</span><em><span class="pre">evq</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_inited" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Check whether the event queue is initialized. </p> |
| <p><dl class="simple"> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: The event queue to check </p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_put"> |
| <span class="target" id="group___o_s_event_1ga00853fd6e0f5bbf39e3930ee70665755"></span><span class="pre">void</span> <code class="sig-name descname"><span class="pre">os_eventq_put</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a><span class="pre">*</span>, <em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_event" title="os_event"><span class="pre">os_event</span></a><span class="pre">*</span><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_put" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Put an event on the event queue. </p> |
| <p><dl class="simple"> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: The event queue to put an event on </p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">ev</span></code>: The event to put on the queue </p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_get_no_wait"> |
| <span class="target" id="group___o_s_event_1ga5142a879bb51db18fa7ff725a81e13d0"></span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_event" title="os_event"><span class="pre">os_event</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">os_eventq_get_no_wait</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a> <span class="pre">*</span><em><span class="pre">evq</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_get_no_wait" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Poll an event from the event queue and return it immediately. </p> |
| <p>If no event is available, don’t block, just return NULL.</p> |
| <p><dl class="simple"> |
| <dt><strong>Return</strong></dt><dd><p>Event from the queue, or NULL if none available. </p> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_get"> |
| <span class="target" id="group___o_s_event_1ga5d4a42f82a5fd7c2911ad4cb61a78045"></span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_event" title="os_event"><span class="pre">os_event</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">os_eventq_get</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a><span class="pre">*</span><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_get" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Pull a single item from an event queue. </p> |
| <p>This function blocks until there is an item on the event queue to read.</p> |
| <p><dl class="simple"> |
| <dt><strong>Return</strong></dt><dd><p>The event from the queue </p> |
| </dd> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: The event queue to pull an event from</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_run"> |
| <span class="target" id="group___o_s_event_1ga5ccd457fe11fddc18f30e9155167948f"></span><span class="pre">void</span> <code class="sig-name descname"><span class="pre">os_eventq_run</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a> <span class="pre">*</span><em><span class="pre">evq</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_run" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Pull a single item off the event queue and call it’s event callback. </p> |
| <p><dl class="simple"> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: The event queue to pull the item off. </p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_poll"> |
| <span class="target" id="group___o_s_event_1ga75902d07b868e820357767c4aae2e175"></span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_event" title="os_event"><span class="pre">os_event</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">os_eventq_poll</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a><span class="pre">*</span><span class="pre">*</span>, <span class="pre">int</span>, <a class="reference internal" href="../time/os_time.html#c.os_time_t" title="os_time_t"><span class="pre">os_time_t</span></a><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_poll" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Poll the list of event queues specified by the evq parameter (size nevqs), and return the “first” event available on any of the queues. </p> |
| <p>Event queues are searched in the order that they are passed in the array.</p> |
| <p><dl class="simple"> |
| <dt><strong>Return</strong></dt><dd><p>An event, or NULL if no events available </p> |
| </dd> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: Array of event queues </p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">nevqs</span></code>: Number of event queues in evq </p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">timo</span></code>: Timeout, forever if OS_WAIT_FOREVER is passed to poll.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_remove"> |
| <span class="target" id="group___o_s_event_1ga74c23f0cc51953fa974cfb09e9bb646a"></span><span class="pre">void</span> <code class="sig-name descname"><span class="pre">os_eventq_remove</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a><span class="pre">*</span>, <em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_event" title="os_event"><span class="pre">os_event</span></a><span class="pre">*</span><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_remove" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Remove an event from the queue. </p> |
| <p><dl class="simple"> |
| <dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">evq</span></code>: The event queue to remove the event from </p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">ev</span></code>: The event to remove from the queue </p></li> |
| </ul> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.os_eventq_dflt_get"> |
| <span class="target" id="group___o_s_event_1gacb92d16784e50c39fc62c92748d3a72d"></span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.os_eventq" title="os_eventq"><span class="pre">os_eventq</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">os_eventq_dflt_get</span></code><span class="sig-paren">(</span><span class="pre">void</span><span class="sig-paren">)</span><a class="headerlink" href="#c.os_eventq_dflt_get" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Retrieves the default event queue processed by OS main task. </p> |
| <p><dl class="simple"> |
| <dt><strong>Return</strong></dt><dd><p>The default event queue. </p> |
| </dd> |
| </dl> |
| </p> |
| </dd></dl> |
| |
| <dl class="c macro"> |
| <dt id="c.OS_EVENT_QUEUED"> |
| <span class="target" id="group___o_s_event_1gaf8776b7d4a3a3374e89562eefb3f3df2"></span><code class="sig-name descname"><span class="pre">OS_EVENT_QUEUED</span></code><span class="sig-paren">(</span><em><span class="pre">__ev</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.OS_EVENT_QUEUED" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Return whether or not the given event is queued. </p> |
| </dd></dl> |
| |
| <dl class="c struct"> |
| <dt id="c.os_event"> |
| <span class="target" id="structos__event"></span><em class="property"><span class="pre">struct</span> </em><code class="sig-name descname"><span class="pre">os_event</span></code><a class="headerlink" href="#c.os_event" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><em>#include <os_eventq.h></em><p>Structure representing an OS event. </p> |
| <p>OS events get placed onto the event queues and are consumed by tasks. </p> |
| <div class="breathe-sectiondef docutils container"> |
| <p class="breathe-sectiondef-title rubric" id="breathe-section-title-public-members">Public Members</p> |
| <dl class="c var"> |
| <dt id="c.os_event.ev_queued"> |
| <span class="target" id="structos__event_1a22704177c6946c3bbb9f30dd8dca1b68"></span><span class="pre">uint8_t</span> <code class="sig-name descname"><span class="pre">ev_queued</span></code><a class="headerlink" href="#c.os_event.ev_queued" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Whether this OS event is queued on an event queue. </p> |
| </dd></dl> |
| |
| <dl class="c var"> |
| <dt id="c.os_event.ev_cb"> |
| <span class="target" id="structos__event_1adce337a55ab01bf317fcd9048b4fb97d"></span><a class="reference internal" href="#c.os_event_fn" title="os_event_fn"><span class="pre">os_event_fn</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">ev_cb</span></code><a class="headerlink" href="#c.os_event.ev_cb" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Callback to call when the event is taken off of an event queue. </p> |
| <p>APIs, except for <a class="reference internal" href="#group___o_s_event_1ga5ccd457fe11fddc18f30e9155167948f"><span class="std std-ref">os_eventq_run()</span></a>, assume this callback will be called by the user. </p> |
| </dd></dl> |
| |
| <dl class="c var"> |
| <dt id="c.os_event.ev_arg"> |
| <span class="target" id="structos__event_1affb49e14dcf2b9e1b6f10bac3da788f1"></span><span class="pre">void</span> <span class="pre">*</span><code class="sig-name descname"><span class="pre">ev_arg</span></code><a class="headerlink" href="#c.os_event.ev_arg" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Argument to pass to the event queue callback. </p> |
| </dd></dl> |
| |
| </div> |
| </dd></dl> |
| |
| <dl class="c struct"> |
| <dt id="c.os_eventq"> |
| <span class="target" id="structos__eventq"></span><em class="property"><span class="pre">struct</span> </em><code class="sig-name descname"><span class="pre">os_eventq</span></code><a class="headerlink" href="#c.os_eventq" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><em>#include <os_eventq.h></em><div class="breathe-sectiondef docutils container"> |
| <p class="breathe-sectiondef-title rubric" id="breathe-section-title-public-members">Public Members</p> |
| <dl class="c var"> |
| <dt id="c.os_eventq.evq_owner"> |
| <span class="target" id="structos__eventq_1a4f44bc0985277390484d7b5cb6b0e35c"></span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="../task/task.html#c.os_task" title="os_task"><span class="pre">os_task</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">evq_owner</span></code><a class="headerlink" href="#c.os_eventq.evq_owner" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Pointer to task that “owns” this event queue. </p> |
| </dd></dl> |
| |
| <dl class="c var"> |
| <dt id="c.os_eventq.evq_task"> |
| <span class="target" id="structos__eventq_1afba1a5b1c24f170c4fe65c186a9257f8"></span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="../task/task.html#c.os_task" title="os_task"><span class="pre">os_task</span></a> <span class="pre">*</span><code class="sig-name descname"><span class="pre">evq_task</span></code><a class="headerlink" href="#c.os_eventq.evq_task" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Pointer to the task that is sleeping on this event queue, either NULL, or the owner task. </p> |
| </dd></dl> |
| |
| </div> |
| </dd></dl> |
| |
| </div> |
| </div> |
| |
| |
| </div> |
| </div> |
| |
| <div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation"> |
| |
| <a href="../callout/callout.html" class="btn btn-neutral float-right" title="Callout" accesskey="n">Next: Callout <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="../semaphore/semaphore.html" class="btn btn-neutral" title="Semaphore" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Semaphore</a> |
| |
| </div> |
| |
| </div> |
| </div> |
| </div> |
| <!-- ENDS CONTENT SECTION --> |
| </div> |
| <!-- ENDS .content --> |
| </div> |
| </div> |
| <footer> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-xs-12"> |
| |
| <p class="copyright">Apache Mynewt is available under Apache License, version 2.0.</p> |
| |
| </div> |
| <div class="col-xs-12"> |
| <div class="logos"> |
| <img src="../../../_static/img/asf_logo_wide_small.png" alt="Apache" title="Apache"> |
| <small class="footnote"> |
| Apache Mynewt, Mynewt, Apache, the Apache feather logo, and the Apache Mynewt project logo are either |
| registered trademarks or trademarks of the Apache Software Foundation in the United States and other countries. |
| </small> |
| <a href=""> |
| <img src="../../../_static/img/add_to_slack.png" alt="Slack Icon" title="Join our Slack Community" /> |
| </a> |
| </div> |
| </div> |
| </div> |
| </div> |
| </footer> |
| </div> |
| <!-- ENDS #wrapper --> |
| |
| |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT:'../../../', |
| VERSION:'latest', |
| COLLAPSE_INDEX:false, |
| FILE_SUFFIX:'.html', |
| HAS_SOURCE: true, |
| SOURCELINK_SUFFIX: '.txt', |
| LINK_SUFFIX: '.html' |
| }; |
| </script> |
| <script type="text/javascript" src="../../../_static/jquery.js"></script> |
| <script type="text/javascript" src="../../../_static/underscore.js"></script> |
| <script type="text/javascript" src="../../../_static/doctools.js"></script> |
| <script type="text/javascript" src="../../../_static/js/bootstrap-3.0.3.min.js"></script> |
| <script type="text/javascript" src="../../../_static/js/affix.js"></script> |
| <script type="text/javascript" src="../../../_static/js/main.js"></script> |
| |
| |
| |
| </body> |
| </html> |