ps/rdma/rdma_common.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <atomic> | ||
| 4 | #include <chrono> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <cstdlib> | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | #include <folly/portability/GFlags.h> | ||
| 10 | |||
| 11 | DECLARE_string(rdma_rc_namespace); | ||
| 12 | |||
| 13 | namespace petps { | ||
| 14 | |||
| 15 | ✗ | inline std::uint64_t NowNs() { | |
| 16 | return static_cast<std::uint64_t>( | ||
| 17 | ✗ | std::chrono::duration_cast<std::chrono::nanoseconds>( | |
| 18 | ✗ | std::chrono::steady_clock::now().time_since_epoch()) | |
| 19 | ✗ | .count()); | |
| 20 | } | ||
| 21 | |||
| 22 | ✗ | inline std::uint64_t Exchange(std::atomic<std::uint64_t>* value) { | |
| 23 | ✗ | return value->exchange(0, std::memory_order_relaxed); | |
| 24 | } | ||
| 25 | |||
| 26 | 2 | inline std::string NamespaceToken() { | |
| 27 | 2 | if (!FLAGS_rdma_rc_namespace.empty()) { | |
| 28 | ✗ | return FLAGS_rdma_rc_namespace; | |
| 29 | } | ||
| 30 | 2 | return "default"; | |
| 31 | } | ||
| 32 | |||
| 33 | inline const std::int32_t* FixedSlotStatusWord( | ||
| 34 | const void* buffer, std::size_t key_count, std::size_t value_size) { | ||
| 35 | return reinterpret_cast<const std::int32_t*>( | ||
| 36 | reinterpret_cast<const char*>(buffer) + | ||
| 37 | key_count * static_cast<std::size_t>(value_size)); | ||
| 38 | } | ||
| 39 | |||
| 40 | ✗ | inline std::int32_t* FixedSlotStatusWord( | |
| 41 | void* buffer, std::size_t key_count, std::size_t value_size) { | ||
| 42 | return reinterpret_cast<std::int32_t*>( | ||
| 43 | reinterpret_cast<char*>(buffer) + | ||
| 44 | ✗ | key_count * static_cast<std::size_t>(value_size)); | |
| 45 | } | ||
| 46 | |||
| 47 | } // namespace petps | ||
| 48 |