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