Mbed OS Reference
Loading...
Searching...
No Matches
mbed_shared_queues.h
1/*
2 * Copyright (c) 2016-2019 ARM Limited
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef MBED_SHARED_QUEUES_H
18#define MBED_SHARED_QUEUES_H
19
20#include "events/EventQueue.h"
21
22namespace mbed {
23/** \addtogroup events-public-api */
24/** @{*/
25
26/**
27 * Return a pointer to an EventQueue, on which normal tasks can be queued.
28 *
29 * All calls to this return the same EventQueue - it and its dispatch thread
30 * are created on the first call to this function. The dispatch thread
31 * runs at default priority (currently osPriorityNormal).
32 *
33 * The EventQueue returned may be used to call() Events, or to chain() other
34 * EventQueues so that they are run in the same context.
35 *
36 * Events (or chained EventQueues) executing on the normal event queue should
37 * normally take less than 10ms to execute, to avoid starving other users. As
38 * such, users can expect that event latency will typically be 10ms or less,
39 * but could occasionally be significantly higher if many events are queued.
40 *
41 * If an RTOS is not present or the configuration option
42 * `events.shared-dispatch-from-application` is set to true, then this
43 * does not create a dedicated dispatch thread - instead the application is
44 * expected to run the EventQueue's dispatch, for example from main. This is
45 * necessary for the event loop to work without an RTOS, or an RTOS system can
46 * save memory by reusing the main stack.
47 *
48 * @note
49 * mbed_event_queue is not itself IRQ safe. To use the mbed_event_queue in
50 * interrupt context, you must first call `mbed_event_queue()` in threaded
51 * context and store the pointer for later use.
52 *
53 * @return pointer to event queue
54 */
56
57#ifdef MBED_CONF_RTOS_PRESENT
58/**
59 * Return a pointer to an EventQueue, on which small high-priority tasks can
60 * be queues, such as simple deferrals from interrupt.
61 *
62 * All calls to this return the same EventQueue - it and its thread are
63 * created on the first call to this function. The dispatch thread
64 * runs at a high priority (currently osPriorityHigh).
65 *
66 * The EventQueue returned may be used to call() Events, or to chain() other
67 * EventQueues so that they are run in the same context.
68 *
69 * Events (or chained EventQueues) executing on the high-priority event queue
70 * should normally take less than 100us to execute, to avoid starving other
71 * users. As such, users can expect that event latency will typically be 100us
72 * or less, but could occasionally be significantly higher if many events are
73 * queued.
74 *
75 * @note
76 * mbed_highprio_event_queue is not itself IRQ safe. To use the
77 * mbed_highprio_event_queue in interrupt context, you must first call
78 * `mbed_highprio_event_queue()` in threaded context and store the pointer for
79 * later use.
80 *
81 * @return pointer to high-priority event queue
82 */
83
84events::EventQueue *mbed_highprio_event_queue();
85
86#endif // MBED_CONF_RTOS_PRESENT
87
88/** @}*/
89
90}
91
92#endif
EventQueue.
Definition: EventQueue.h:62
events::EventQueue * mbed_event_queue()
Return a pointer to an EventQueue, on which normal tasks can be queued.