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.
Diff: mbed-os/events/EventQueue.cpp
- Revision:
- 0:380207fcb5c1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os/events/EventQueue.cpp Thu Mar 29 07:02:09 2018 +0000
@@ -0,0 +1,66 @@
+/* events
+ * Copyright (c) 2016 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "events/EventQueue.h"
+
+#include "events/mbed_events.h"
+#include "mbed.h"
+
+
+EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer) {
+ if (!event_pointer) {
+ equeue_create(&_equeue, event_size);
+ } else {
+ equeue_create_inplace(&_equeue, event_size, event_pointer);
+ }
+}
+
+EventQueue::~EventQueue() {
+ equeue_destroy(&_equeue);
+}
+
+void EventQueue::dispatch(int ms) {
+ return equeue_dispatch(&_equeue, ms);
+}
+
+void EventQueue::break_dispatch() {
+ return equeue_break(&_equeue);
+}
+
+unsigned EventQueue::tick() {
+ return equeue_tick();
+}
+
+void EventQueue::cancel(int id) {
+ return equeue_cancel(&_equeue, id);
+}
+
+void EventQueue::background(Callback<void(int)> update) {
+ _update = update;
+
+ if (_update) {
+ equeue_background(&_equeue, &Callback<void(int)>::thunk, &_update);
+ } else {
+ equeue_background(&_equeue, 0, 0);
+ }
+}
+
+void EventQueue::chain(EventQueue *target) {
+ if (target) {
+ equeue_chain(&_equeue, &target->_equeue);
+ } else {
+ equeue_chain(&_equeue, 0);
+ }
+}