summaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/pendinglidtracker.h
blob: 4fc718fd465855f1939d9ce48af2e5dd2520da4c (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/hash_map.h>
#include <mutex>
#include <condition_variable>

namespace proton {

class PendingLidTracker {
public:
    PendingLidTracker();
    ~PendingLidTracker();
    void produce(uint32_t lid);
    void consume(uint32_t lid);
    void waitForConsumedLid(uint32_t lid);
private:
    std::mutex _mutex;
    std::condition_variable _cond;
    vespalib::hash_map<uint32_t, uint32_t> _pending;
};

}