im.cc 1.0 KB
Newer Older
S
superjom 已提交
1
#include <glog/logging.h>
S
superjom 已提交
2
#include <ctime>
S
superjom 已提交
3

S
superjom 已提交
4
#include "visualdl/logic/im.h"
S
superjom 已提交
5 6 7
#include "visualdl/storage/entry.h"
#include "visualdl/storage/storage.h"
#include "visualdl/storage/tablet.h"
S
superjom 已提交
8 9 10

namespace visualdl {

S
superjom 已提交
11 12 13 14
template <typename T>
void SimpleWriteSyncGuard<T>::Start() {
  CHECK(data_);
  data_->parent()->meta.Inc();
S
superjom 已提交
15 16
}

S
superjom 已提交
17 18 19 20 21
template <typename T>
void SimpleWriteSyncGuard<T>::End() {
  CHECK(data_);
  if (data_->parent()->meta.ToSync()) {
    Sync();
S
superjom 已提交
22 23 24
  }
}

S
superjom 已提交
25 26 27 28 29
template <typename T>
void SimpleWriteSyncGuard<T>::Sync() {
  CHECK(data_);
  auto* storage = data_->parent();
  storage->PersistToDisk();
S
superjom 已提交
30 31
}

S
superjom 已提交
32 33 34
template class SimpleWriteSyncGuard<Storage>;
template class SimpleWriteSyncGuard<Tablet>;
template class SimpleWriteSyncGuard<Record>;
S
superjom 已提交
35 36 37 38 39 40
template class SimpleWriteSyncGuard<Entry<float>>;
template class SimpleWriteSyncGuard<Entry<double>>;
template class SimpleWriteSyncGuard<Entry<bool>>;
template class SimpleWriteSyncGuard<Entry<long>>;
template class SimpleWriteSyncGuard<Entry<std::string>>;
template class SimpleWriteSyncGuard<Entry<int>>;
S
superjom 已提交
41

S
superjom 已提交
42
}  // namespace visualdl