2019-02-20 23:53:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2019, Arm Limited and affiliates.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2018-05-23 20:56:28 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef POLLED_QUEUE_H
|
|
|
|
#define POLLED_QUEUE_H
|
|
|
|
|
2019-07-18 15:55:26 +00:00
|
|
|
#include "drivers/internal/TaskQueue.h"
|
2018-05-23 20:56:28 +00:00
|
|
|
#include "platform/Callback.h"
|
|
|
|
#include "LinkedList.h"
|
|
|
|
namespace events {
|
2019-07-24 15:59:40 +00:00
|
|
|
/**
|
2019-08-01 10:09:13 +00:00
|
|
|
* \defgroup drivers_PolledQueue PolledQueue class
|
|
|
|
* \ingroup drivers-internal-api-usb
|
2019-07-24 15:59:40 +00:00
|
|
|
* @{
|
|
|
|
*/
|
2018-05-23 20:56:28 +00:00
|
|
|
|
|
|
|
/** PolledQueue
|
|
|
|
*
|
|
|
|
* This class is an implementation of TaskQueue which is
|
|
|
|
* processed synchronously by calls to dispatch.
|
|
|
|
*/
|
|
|
|
class PolledQueue: public TaskQueue {
|
|
|
|
public:
|
|
|
|
|
|
|
|
/** Create a PolledQueue
|
|
|
|
*
|
|
|
|
* Create an event queue.
|
|
|
|
*
|
|
|
|
* @param cb Callback called when dispatch needs to be called
|
|
|
|
*/
|
2019-07-02 14:28:26 +00:00
|
|
|
PolledQueue(mbed::Callback<void()> cb = nullptr);
|
2018-05-23 20:56:28 +00:00
|
|
|
|
|
|
|
virtual ~PolledQueue();
|
|
|
|
|
|
|
|
virtual void post(TaskBase *event);
|
|
|
|
|
|
|
|
virtual void cancel(TaskBase *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process all the events in this queue
|
|
|
|
*/
|
|
|
|
void dispatch();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attach a callback indicating that this queue needs to be processed
|
|
|
|
*
|
|
|
|
* @param cb Callback called when dispatch needs to be called
|
|
|
|
*/
|
|
|
|
void attach(mbed::Callback<void()> cb);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
mbed::Callback<void()> _cb;
|
|
|
|
LinkedList<TaskBase> _list;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-07-11 15:23:39 +00:00
|
|
|
/** @}*/
|
|
|
|
|
2018-05-23 20:56:28 +00:00
|
|
|
}
|
|
|
|
#endif
|