Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EventQueue.h Source File

EventQueue.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2017-2017 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef BLE_PAL_EVENT_QUEUE_H_
00018 #define BLE_PAL_EVENT_QUEUE_H_
00019 
00020 #include "platform/Callback.h"
00021 
00022 namespace ble {
00023 namespace pal {
00024 
00025 /**
00026  * Simple interface which allow upper layer to post an event into the event
00027  * mechanism of the abstracted stack.
00028  *
00029  * When an event is posted then it's availability shall be signaled to the upper
00030  * layer in order to inform the upper layer that events are ready to be
00031  * processed.
00032  *
00033  * Implementation can realize that operation by calling the function
00034  * signalEventsToProcess of their implementation of BLEInstanceBase.
00035  *
00036  * Events in the queue shall be processed at the next invocation of
00037  * BLEInstanceBase::processEvents.
00038  */
00039 struct EventQueue {
00040     /**
00041      * Base constructor of an event queue.
00042      */
00043     EventQueue() { }
00044 
00045     /**
00046      * Destructor, needs to be overiden in implementation
00047      */
00048     ~EventQueue() { }
00049 
00050     /**
00051      * Post an event into the event queue.
00052      *
00053      * @param event The event to store in the queue, it shall be processed at
00054      * the next invocation of BLE::processEvent.
00055      *
00056      * @return true in case of success and false otherwise
00057      *
00058      * @attention Event availability shall be signaled to the upper layer and
00059      * the event queue shall be processed at the next invocation of
00060      * BLEInstanceBase::process
00061      */
00062     virtual bool post(const mbed::Callback<void()>& event) = 0;
00063 };
00064 
00065 } // namespace pal
00066 } // namespace ble
00067 
00068 #endif /* BLE_PAL_EVENT_QUEUE_H_ */