Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OperationListBase.h Source File

OperationListBase.h

00001 /*
00002  * Copyright (c) 2018-2019, Arm Limited and affiliates.
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 
00018 #ifndef MBED_OPERATION_LIST_BASE_H
00019 #define MBED_OPERATION_LIST_BASE_H
00020 
00021 #include "drivers/internal/LinkedListBase.h"
00022 
00023 class AsyncOp;
00024 
00025 /**
00026  * \defgroup drivers_OperationListBase OperationListBase class
00027  * \ingroup drivers-internal-api-usb
00028  * @{
00029  */
00030 class OperationListBase {
00031 public:
00032 
00033     /**
00034      * Create a new empty operation list
00035      */
00036     OperationListBase();
00037 
00038     /**
00039      * Destroy this object and abort all operations
00040      */
00041     ~OperationListBase();
00042 
00043     /**
00044      * Check if the list is empty
00045      *
00046      * @return true if the list is empty false otherwise
00047      */
00048     bool empty();
00049 
00050     /**
00051      * Add an operation to the list
00052      *
00053      * If the list was empty then call process on this
00054      * operation
00055      *
00056      * @param op Operation to add
00057      */
00058     void add(AsyncOp *op);
00059 
00060     /**
00061      * Remove an operation from the list
00062      *
00063      * If this was the head of the list then process the
00064      * next element in the list.
00065      *
00066      * @param op Operation to remove
00067      */
00068     void remove(AsyncOp *op);
00069 
00070     /**
00071      * Dequeue the head of the list
00072      *
00073      * Remove the head of the operation list without completing it
00074      * or processing the next element. The caller must call the
00075      * AsnycOp::complete() function of the returned object.
00076      * Additionally process() must be called on this object
00077      * if there are still elements in the list.
00078      *
00079      * @return The asynchronous op at the head of the list
00080      */
00081     AsyncOp *dequeue_raw();
00082 
00083     /**
00084      * Abort all operations
00085      */
00086     void remove_all();
00087 
00088     /**
00089      * Process the operation list
00090      *
00091      * This allow the operation at the head of the list to perform processing
00092      */
00093     void process();
00094 
00095 private:
00096     friend class AsyncOp;
00097 
00098     LinkedListBase _list;
00099 };
00100 
00101 /** @}*/
00102 
00103 #endif