forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpausable_ack_queue.h
36 lines (29 loc) · 1.09 KB
/
pausable_ack_queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include <list>
#include "source/common/config/update_ack.h"
#include "absl/container/flat_hash_map.h"
namespace Envoy {
namespace Config {
// There is a head-of-line blocking issue resulting from the intersection of 1) ADS's need for
// subscription request ordering and 2) the ability to "pause" one of the resource types within ADS.
// We need a queue that understands ADS's resource type pausing. Specifically, we need front()/pop()
// to choose the first element whose type_url isn't paused.
class PausableAckQueue {
public:
void push(UpdateAck x);
size_t size() const;
bool empty();
const UpdateAck& front();
UpdateAck popFront();
void pause(const std::string& type_url);
void resume(const std::string& type_url);
bool paused(const std::string& type_url) const;
void clear();
private:
// It's ok for non-existent subs to be paused/resumed. The cleanest way to support that is to give
// the pause state its own map. (Map key is type_url.)
absl::flat_hash_map<std::string, uint32_t> pauses_;
std::list<UpdateAck> storage_;
};
} // namespace Config
} // namespace Envoy