1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license.
3
4#pragma once
5
6#include <atomic>
7#include <cstdint>
8
9namespace FASTER {
10namespace core {
11
12/// State of the active garbage-collection call.
13class GcState {
14 public:
15 typedef void(*truncate_callback_t)(uint64_t offset);
16 typedef void(*complete_callback_t)(void);
17
18 GcState()
19 : truncate_callback{ nullptr }
20 , complete_callback{ nullptr }
21 , num_chunks{ 0 }
22 , next_chunk{ 0 } {
23 }
24
25 void Initialize(truncate_callback_t truncate_callback_, complete_callback_t complete_callback_,
26 uint64_t num_chunks_) {
27 truncate_callback = truncate_callback_;
28 complete_callback = complete_callback_;
29 num_chunks = num_chunks_;
30 next_chunk = 0;
31 }
32
33 truncate_callback_t truncate_callback;
34 complete_callback_t complete_callback;
35 uint64_t num_chunks;
36 std::atomic<uint64_t> next_chunk;
37};
38
39}
40} // namespace FASTER::core
41