| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <atomic> |
| 7 | #include <chrono> |
| 8 | #include <cstdint> |
| 9 | #include <cstring> |
| 10 | #include <functional> |
| 11 | #include <memory> |
| 12 | #include <thread> |
| 13 | |
| 14 | #include "alloc.h" |
| 15 | #include "async.h" |
| 16 | #include "constants.h" |
| 17 | #include "thread.h" |
| 18 | #include "utility.h" |
| 19 | |
| 20 | namespace FASTER { |
| 21 | namespace core { |
| 22 | |
| 23 | /// Phases, used internally by FASTER to keep track of how far along FASTER has gotten during |
| 24 | /// checkpoint, gc, and grow actions. |
| 25 | enum class Phase : uint8_t { |
| 26 | /// Checkpoint phases. |
| 27 | PREP_INDEX_CHKPT, |
| 28 | INDEX_CHKPT, |
| 29 | PREPARE, |
| 30 | IN_PROGRESS, |
| 31 | WAIT_PENDING, |
| 32 | WAIT_FLUSH, |
| 33 | REST, |
| 34 | PERSISTENCE_CALLBACK, |
| 35 | /// Garbage-collection phases. |
| 36 | /// - The log's begin-address has been shifted; finish all outstanding I/Os before trying to |
| 37 | /// truncate the log. |
| 38 | GC_IO_PENDING, |
| 39 | /// - The log has been truncated, but threads are still cleaning the hash table. |
| 40 | GC_IN_PROGRESS, |
| 41 | /// Grow-index phases. |
| 42 | /// - Each thread waits for all other threads to complete outstanding (synchronous) operations |
| 43 | /// against the hash table. |
| 44 | GROW_PREPARE, |
| 45 | /// - Each thread copies a chunk of the old hash table into the new hash table. |
| 46 | GROW_IN_PROGRESS, |
| 47 | INVALID |
| 48 | }; |
| 49 | |
| 50 | } |
| 51 | } // namespace FASTER::core |