Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_shared_queues.h Source File

mbed_shared_queues.h

00001 
00002 /** \addtogroup events */
00003 /** @{*/
00004 /* events
00005  * Copyright (c) 2017 ARM Limited
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 #ifndef MBED_SHARED_QUEUES_H
00020 #define MBED_SHARED_QUEUES_H
00021 
00022 #include "events/EventQueue.h"
00023 
00024 namespace mbed {
00025 
00026 /**
00027  * Return a pointer to an EventQueue, on which normal tasks can be queued.
00028  *
00029  * All calls to this return the same EventQueue - it and its dispatch thread
00030  * are created on the first call to this function. The dispatch thread
00031  * runs at default priority (currently osPriorityNormal).
00032  *
00033  * The EventQueue returned may be used to call() Events, or to chain() other
00034  * EventQueues so that they are run in the same context.
00035  *
00036  * Events (or chained EventQueues) executing on the normal event queue should
00037  * normally take less than 10ms to execute, to avoid starving other users. As
00038  * such, users can expect that event latency will typically be 10ms or less,
00039  * but could occasionally be significantly higher if many events are queued.
00040  *
00041  * If an RTOS is not present or the configuration option
00042  * `events.shared-dispatch-from-application` is set to true, then this
00043  * does not create a dedicated dispatch thread - instead the application is
00044  * expected to run the EventQueue's dispatch, eg from main. This is necessary
00045  * for the event loop to work without an RTOS, or an RTOS system can can save
00046  * memory by reusing the main stack.
00047  *
00048  * @note
00049  * mbed_event_queue is not itself IRQ safe. To use the mbed_event_queue in
00050  * interrupt context, you must first call `mbed_event_queue()` in threaded
00051  * context and store the pointer for later use.
00052  *
00053  * @return pointer to event queue
00054  */
00055 events::EventQueue *mbed_event_queue();
00056 
00057 #ifdef MBED_CONF_RTOS_PRESENT
00058 /**
00059  * Return a pointer to an EventQueue, on which small high-priority tasks can
00060  * be queues, such as simple deferrals from interrupt.
00061  *
00062  * All calls to this return the same EventQueue - it and its thread are
00063  * created on the first call to this function. The dispatch thread
00064  * runs at a high priority (currently osPriorityHigh).
00065  *
00066  * The EventQueue returned may be used to call() Events, or to chain() other
00067  * EventQueues so that they are run in the same context.
00068  *
00069  * Events (or chained EventQueues) executing on the high-priority event queue
00070  * should normally take less than 100us to execute, to avoid starving other
00071  * users. As such, users can expect that event latency will typically be 100us
00072  * or less, but could occasionally be significantly higher if many events are
00073  * queued.
00074  *
00075  * @note
00076  * mbed_highprio_event_queue is not itself IRQ safe. To use the
00077  * mbed_highprio_event_queue in interrupt context, you must first call
00078  * `mbed_event_queue()` in threaded context and store the pointer for
00079  * later use.
00080  *
00081  * @return pointer to high-priority event queue
00082  */
00083 
00084 events::EventQueue *mbed_highprio_event_queue();
00085 
00086 #endif // MBED_CONF_RTOS_PRESENT
00087 
00088 };
00089 
00090 #endif
00091 
00092 /** @}*/