1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "os/queue.h"
20 
21 namespace bluetooth {
22 namespace os {
23 namespace fuzz {
24 
25 // Drops stuff you send it, and banishes it into the void.
26 template <typename T>
27 class DevNullQueue {
28  public:
DevNullQueue(IQueueDequeue<T> * queue,Handler * handler)29   DevNullQueue(IQueueDequeue<T>* queue, Handler* handler) : queue_(queue), handler_(handler) {}
~DevNullQueue()30   ~DevNullQueue() {}
31 
Start()32   void Start() {
33     queue_->RegisterDequeue(handler_, common::Bind(&DevNullQueue::Dump, common::Unretained(this)));
34   }
35 
Stop()36   void Stop() {
37     queue_->UnregisterDequeue();
38   }
39 
Dump()40   void Dump() {
41     queue_->TryDequeue();
42   }
43 
44  private:
45   IQueueDequeue<T>* queue_;
46   Handler* handler_;
47 };
48 
49 }  // namespace fuzz
50 }  // namespace os
51 }  // namespace bluetooth
52