blob: 3ad80f4e55d9e691285dd5ed6cd6827acb8d0d03 (
plain) (
blame)
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
37
38
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <map>
#include <vespa/storageapi/messageapi/storagemessage.h>
namespace storage::distributor {
class Operation;
class SentMessageMap {
public:
using Map = std::map<api::StorageMessage::Id, std::shared_ptr<Operation>>;
SentMessageMap();
~SentMessageMap();
// Find by message ID, or nullptr if not found
[[nodiscard]] Operation* find_by_id_or_nullptr(api::StorageMessage::Id id) const noexcept;
// Find by message ID, or empty shared_ptr if not found
[[nodiscard]] std::shared_ptr<Operation> find_by_id_or_empty(api::StorageMessage::Id id) const noexcept;
[[nodiscard]] std::shared_ptr<Operation> pop(api::StorageMessage::Id id);
[[nodiscard]] std::shared_ptr<Operation> pop();
void insert(api::StorageMessage::Id id, const std::shared_ptr<Operation> & msg);
void clear();
[[nodiscard]] uint32_t size() const { return _map.size(); }
[[nodiscard]] bool empty() const noexcept { return _map.empty(); }
std::string toString() const;
Map::const_iterator begin() const noexcept { return _map.cbegin(); }
Map::const_iterator end() const noexcept { return _map.cend(); }
private:
Map _map;
};
}
|