Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
EventQueue.cpp
00001 /* events 00002 * Copyright (c) 2016-2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #include "events/EventQueue.h" 00018 #include "events/mbed_events.h" 00019 00020 using mbed::Callback; 00021 00022 namespace events { 00023 00024 EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer) 00025 { 00026 if (event_size == 0) { 00027 // As static queue (EventQueue(0)) won't perform any access to its data buffer 00028 // we can pass (0, NULL) 00029 equeue_create_inplace(&_equeue, 0, NULL); 00030 } else { 00031 if (!event_pointer) { 00032 equeue_create(&_equeue, event_size); 00033 } else { 00034 equeue_create_inplace(&_equeue, event_size, event_pointer); 00035 } 00036 } 00037 } 00038 00039 EventQueue::~EventQueue() 00040 { 00041 equeue_destroy(&_equeue); 00042 } 00043 00044 void EventQueue::dispatch(int ms) 00045 { 00046 return equeue_dispatch(&_equeue, ms); 00047 } 00048 00049 void EventQueue::break_dispatch() 00050 { 00051 return equeue_break(&_equeue); 00052 } 00053 00054 unsigned EventQueue::tick() 00055 { 00056 return equeue_tick(); 00057 } 00058 00059 bool EventQueue::cancel(int id) 00060 { 00061 return equeue_cancel(&_equeue, id); 00062 } 00063 00064 int EventQueue::time_left(int id) 00065 { 00066 return equeue_timeleft(&_equeue, id); 00067 } 00068 00069 void EventQueue::background(Callback<void(int)> update) 00070 { 00071 _update = update; 00072 00073 if (_update) { 00074 equeue_background(&_equeue, &Callback<void(int)>::thunk, &_update); 00075 } else { 00076 equeue_background(&_equeue, 0, 0); 00077 } 00078 } 00079 00080 int EventQueue::chain(EventQueue *target) 00081 { 00082 if (target) { 00083 return equeue_chain(&_equeue, &target->_equeue); 00084 } else { 00085 return equeue_chain(&_equeue, 0); 00086 } 00087 } 00088 }
Generated on Tue Jul 12 2022 13:54:19 by
