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