|
| 1 | + |
| 2 | +/** \addtogroup events */ |
| 3 | +/** @{*/ |
| 4 | +/* events |
| 5 | + * Copyright (c) 2017 ARM Limited |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | +#ifndef MBED_SHARED_QUEUES_H |
| 20 | +#define MBED_SHARED_QUEUES_H |
| 21 | + |
| 22 | +#include "events/EventQueue.h" |
| 23 | + |
| 24 | +namespace mbed { |
| 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, eg from main. This is necessary |
| 45 | + * for the event loop to work without an RTOS, or an RTOS system can can save |
| 46 | + * memory by reusing the main stack. |
| 47 | + * |
| 48 | + * @return pointer to event queue |
| 49 | + */ |
| 50 | +events::EventQueue *mbed_event_queue(); |
| 51 | + |
| 52 | +#ifdef MBED_CONF_RTOS_PRESENT |
| 53 | +/** |
| 54 | + * Return a pointer to an EventQueue, on which small high-priority tasks can |
| 55 | + * be queues, such as simple deferrals from interrupt. |
| 56 | + * |
| 57 | + * All calls to this return the same EventQueue - it and its thread are |
| 58 | + * created on the first call to this function. The dispatch thread |
| 59 | + * runs at a high priority (currently osPriorityHigh). |
| 60 | + * |
| 61 | + * The EventQueue returned may be used to call() Events, or to chain() other |
| 62 | + * EventQueues so that they are run in the same context. |
| 63 | + * |
| 64 | + * Events (or chained EventQueues) executing on the high-priority event queue |
| 65 | + * should normally take less than 100us to execute, to avoid starving other |
| 66 | + * users. As such, users can expect that event latency will typically be 100us |
| 67 | + * or less, but could occasionally be significantly higher if many events are |
| 68 | + * queued. |
| 69 | + * |
| 70 | + * @return pointer to high-priority event queue |
| 71 | + */ |
| 72 | + |
| 73 | +events::EventQueue *mbed_highprio_event_queue(); |
| 74 | + |
| 75 | +#endif // MBED_CONF_RTOS_PRESENT |
| 76 | + |
| 77 | +}; |
| 78 | + |
| 79 | +#endif |
| 80 | + |
| 81 | +/** @}*/ |
0 commit comments