BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:fbdae7e6d805 1 /* events
borlanic 0:fbdae7e6d805 2 * Copyright (c) 2016 ARM Limited
borlanic 0:fbdae7e6d805 3 *
borlanic 0:fbdae7e6d805 4 * Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:fbdae7e6d805 5 * you may not use this file except in compliance with the License.
borlanic 0:fbdae7e6d805 6 * You may obtain a copy of the License at
borlanic 0:fbdae7e6d805 7 *
borlanic 0:fbdae7e6d805 8 * http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:fbdae7e6d805 9 *
borlanic 0:fbdae7e6d805 10 * Unless required by applicable law or agreed to in writing, software
borlanic 0:fbdae7e6d805 11 * distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:fbdae7e6d805 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:fbdae7e6d805 13 * See the License for the specific language governing permissions and
borlanic 0:fbdae7e6d805 14 * limitations under the License.
borlanic 0:fbdae7e6d805 15 */
borlanic 0:fbdae7e6d805 16 #include "events/EventQueue.h"
borlanic 0:fbdae7e6d805 17
borlanic 0:fbdae7e6d805 18 #include "events/mbed_events.h"
borlanic 0:fbdae7e6d805 19 #include "mbed.h"
borlanic 0:fbdae7e6d805 20
borlanic 0:fbdae7e6d805 21
borlanic 0:fbdae7e6d805 22 EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer) {
borlanic 0:fbdae7e6d805 23 if (!event_pointer) {
borlanic 0:fbdae7e6d805 24 equeue_create(&_equeue, event_size);
borlanic 0:fbdae7e6d805 25 } else {
borlanic 0:fbdae7e6d805 26 equeue_create_inplace(&_equeue, event_size, event_pointer);
borlanic 0:fbdae7e6d805 27 }
borlanic 0:fbdae7e6d805 28 }
borlanic 0:fbdae7e6d805 29
borlanic 0:fbdae7e6d805 30 EventQueue::~EventQueue() {
borlanic 0:fbdae7e6d805 31 equeue_destroy(&_equeue);
borlanic 0:fbdae7e6d805 32 }
borlanic 0:fbdae7e6d805 33
borlanic 0:fbdae7e6d805 34 void EventQueue::dispatch(int ms) {
borlanic 0:fbdae7e6d805 35 return equeue_dispatch(&_equeue, ms);
borlanic 0:fbdae7e6d805 36 }
borlanic 0:fbdae7e6d805 37
borlanic 0:fbdae7e6d805 38 void EventQueue::break_dispatch() {
borlanic 0:fbdae7e6d805 39 return equeue_break(&_equeue);
borlanic 0:fbdae7e6d805 40 }
borlanic 0:fbdae7e6d805 41
borlanic 0:fbdae7e6d805 42 unsigned EventQueue::tick() {
borlanic 0:fbdae7e6d805 43 return equeue_tick();
borlanic 0:fbdae7e6d805 44 }
borlanic 0:fbdae7e6d805 45
borlanic 0:fbdae7e6d805 46 void EventQueue::cancel(int id) {
borlanic 0:fbdae7e6d805 47 return equeue_cancel(&_equeue, id);
borlanic 0:fbdae7e6d805 48 }
borlanic 0:fbdae7e6d805 49
borlanic 0:fbdae7e6d805 50 void EventQueue::background(Callback<void(int)> update) {
borlanic 0:fbdae7e6d805 51 _update = update;
borlanic 0:fbdae7e6d805 52
borlanic 0:fbdae7e6d805 53 if (_update) {
borlanic 0:fbdae7e6d805 54 equeue_background(&_equeue, &Callback<void(int)>::thunk, &_update);
borlanic 0:fbdae7e6d805 55 } else {
borlanic 0:fbdae7e6d805 56 equeue_background(&_equeue, 0, 0);
borlanic 0:fbdae7e6d805 57 }
borlanic 0:fbdae7e6d805 58 }
borlanic 0:fbdae7e6d805 59
borlanic 0:fbdae7e6d805 60 void EventQueue::chain(EventQueue *target) {
borlanic 0:fbdae7e6d805 61 if (target) {
borlanic 0:fbdae7e6d805 62 equeue_chain(&_equeue, &target->_equeue);
borlanic 0:fbdae7e6d805 63 } else {
borlanic 0:fbdae7e6d805 64 equeue_chain(&_equeue, 0);
borlanic 0:fbdae7e6d805 65 }
borlanic 0:fbdae7e6d805 66 }