1

Committer:
valeyev
Date:
Tue Mar 13 07:17:50 2018 +0000
Revision:
0:e056ac8fecf8
looking for...

Who changed what in which revision?

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