DebugServer2
Loading...
Searching...
No Matches
MessageQueue.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/Base.h"
14
15#include <condition_variable>
16#include <deque>
17#include <mutex>
18#include <string>
19
20namespace ds2 {
21
23private:
24 std::deque<std::string> _messages;
25 std::condition_variable _ready;
26 std::mutex _lock;
27 bool _terminated;
28
29public:
31
32public:
33 void put(std::string const &message);
34 std::string get(int wait = -1); // Wait is expressed in milliseconds
35
36 // Wait until the queue is non-empty. Returns false if
37 // the queue is empty after the timeout, true otherwise.
38 // (Note that get() may still block after returning if
39 // another thread pulls from the queue.)
40 bool wait(int ms = -1);
41
42public:
43 void clear(bool terminating);
44};
45} // namespace ds2
Definition MessageQueue.h:22