Snapshots
This commit is contained in:
@@ -31,6 +31,9 @@
|
||||
#include <unordered_map>
|
||||
#include <fstream>
|
||||
#include "ofstream_synced.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
using namespace pipedal;
|
||||
|
||||
namespace config_serializer
|
||||
{
|
||||
@@ -38,8 +41,6 @@ namespace config_serializer
|
||||
{
|
||||
std::string trim(const std::string &v);
|
||||
|
||||
std::vector<std::string> split(const std::string &v, char seperator);
|
||||
|
||||
/**
|
||||
* @brief Convert string to config file format.
|
||||
*
|
||||
|
||||
@@ -586,7 +586,11 @@ namespace pipedal
|
||||
template <typename T>
|
||||
void write(const std::shared_ptr<T> &obj)
|
||||
{
|
||||
write(obj.get());
|
||||
if (!obj) {
|
||||
write_raw("null");
|
||||
} else {
|
||||
write(obj.get());
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void write(const std::weak_ptr<T> &obj)
|
||||
@@ -865,10 +869,18 @@ namespace pipedal
|
||||
template <typename T>
|
||||
void read(std::shared_ptr<T> *pUniquePtr)
|
||||
{
|
||||
std::shared_ptr<T> p = std::make_shared<T>();
|
||||
if (peek() == 'n')
|
||||
{
|
||||
consumeToken("null", "Expecting '{' or 'null'.");
|
||||
*pUniquePtr = nullptr;
|
||||
|
||||
read(p.get());
|
||||
(*pUniquePtr) = std::move(p);
|
||||
} else
|
||||
{
|
||||
std::shared_ptr<T> p = std::make_shared<T>();
|
||||
|
||||
read(p.get());
|
||||
(*pUniquePtr) = std::move(p);
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void read(std::weak_ptr<T> *pUniquePtr)
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <barrier>
|
||||
#include <atomic>
|
||||
|
||||
namespace pipedal {
|
||||
|
||||
@@ -38,4 +41,30 @@ namespace pipedal {
|
||||
|
||||
std::string GetHostName();
|
||||
|
||||
std::vector<std::string> split(const std::string &value, char delimiter);
|
||||
|
||||
inline void ReadBarrier() {
|
||||
std::atomic_thread_fence(std::memory_order::acquire);
|
||||
}
|
||||
inline void WriteBarrier() {
|
||||
std::atomic_thread_fence(std::memory_order::release);
|
||||
|
||||
}
|
||||
|
||||
class NoCopy {
|
||||
public:
|
||||
NoCopy() { }
|
||||
NoCopy(const NoCopy&) = delete;
|
||||
NoCopy&operator=(const NoCopy&) = delete;
|
||||
~NoCopy() {}
|
||||
};
|
||||
class NoMove {
|
||||
public:
|
||||
NoMove() { }
|
||||
NoMove(NoMove&&) = delete;
|
||||
NoMove&operator=(NoMove&&) = delete;
|
||||
~NoMove() { }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user