Mbed OS Reference
Loading...
Searching...
No Matches
PolledQueue.h
1/*
2 * Copyright (c) 2018-2019, Arm Limited and affiliates.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef POLLED_QUEUE_H
19#define POLLED_QUEUE_H
20
21#include "usb/internal/TaskQueue.h"
22#include "platform/Callback.h"
23#include "LinkedList.h"
24
25namespace events {
26/**
27 * \defgroup drivers_PolledQueue PolledQueue class
28 * \ingroup drivers-internal-api-usb
29 * @{
30 */
31
32/** PolledQueue
33 *
34 * This class is an implementation of TaskQueue which is
35 * processed synchronously by calls to dispatch.
36 */
37class PolledQueue: public TaskQueue {
38public:
39
40 /** Create a PolledQueue
41 *
42 * Create an event queue.
43 *
44 * @param cb Callback called when dispatch needs to be called
45 */
46 PolledQueue(mbed::Callback<void()> cb = nullptr);
47
48 virtual ~PolledQueue();
49
50 virtual void post(TaskBase *event);
51
52 virtual void cancel(TaskBase *event);
53
54 /**
55 * Process all the events in this queue
56 */
57 void dispatch();
58
59 /**
60 * Attach a callback indicating that this queue needs to be processed
61 *
62 * @param cb Callback called when dispatch needs to be called
63 */
64 void attach(mbed::Callback<void()> cb);
65
66protected:
67
68 mbed::Callback<void()> _cb;
70
71};
72
73/** @}*/
74
75}
76#endif
PolledQueue.
Definition: PolledQueue.h:37
void attach(mbed::Callback< void()> cb)
Attach a callback indicating that this queue needs to be processed.
PolledQueue(mbed::Callback< void()> cb=nullptr)
Create a PolledQueue.
virtual void cancel(TaskBase *event)
Cancel an in-flight event.
void dispatch()
Process all the events in this queue.
virtual void post(TaskBase *event)
Add this event to the queue for execution.
TaskBase.
Definition: TaskBase.h:43
TaskQueue.
Definition: TaskQueue.h:39
Callback class based on template specialization.
Definition: Callback.h:53