diff --git a/visualdl/backend/logic/im.cc b/visualdl/backend/logic/im.cc index 971a9f48f7355a802200341540a3aada82eb464a..817ea6b1b988808f4464e9916fb0802a8a93b13d 100644 --- a/visualdl/backend/logic/im.cc +++ b/visualdl/backend/logic/im.cc @@ -25,6 +25,27 @@ int ReserviorSample(int num_samples, int num_records) { return -1; } +IM::IM(StorageBase::Type type, StorageBase::Mode mode) { + switch (type) { + case StorageBase::Type::kMemory: + storage_.reset(new MemoryStorage); + break; + default: + CHECK(false) << "Unsupported storage kind " << type; + } + + switch (mode) { + case StorageBase::Mode::kRead: + dynamic_cast(storage_.get())->StartReadService(); + break; + case StorageBase::Mode::kWrite: + dynamic_cast(storage_.get())->StartWriteSerice(); + break; + default: + break; + } +} + void IM::SetPersistDest(const std::string &path) { CHECK(storage_->mutable_data()->dir().empty()) << "duplicate set storage's path"; diff --git a/visualdl/backend/logic/im.h b/visualdl/backend/logic/im.h index 603f4294d61828b5ad2de5f73bb8b4c7bf9588cb..1d8245c8b02c0b017c8c3d2354f5f39640977668 100644 --- a/visualdl/backend/logic/im.h +++ b/visualdl/backend/logic/im.h @@ -26,15 +26,8 @@ namespace visualdl { */ class IM final { public: - IM(StorageBase::Type type = StorageBase::Type::kMemory) { - switch (type) { - case StorageBase::Type::kMemory: - storage_.reset(new MemoryStorage); - break; - default: - CHECK(false) << "Unsupported storage kind " << type; - } - } + IM(StorageBase::Type type = StorageBase::Type::kMemory, + StorageBase::Mode mode = StorageBase::Mode::kNone); static IM &Global() { static IM *x = new IM(); diff --git a/visualdl/backend/storage/storage.h b/visualdl/backend/storage/storage.h index 5ccd4564056d55b22db860b0d9c60136770c12e2..a827a6dbd8d936ff6f9c8de9c95289cd8cbff0ee 100644 --- a/visualdl/backend/storage/storage.h +++ b/visualdl/backend/storage/storage.h @@ -27,7 +27,7 @@ public: enum Type { kMemory = 0, kDisk = 1 }; // mode of the sevice, either reading or writing. - enum Mode { kRead = 0, kWrite = 1 }; + enum Mode { kRead = 0, kWrite = 1, kNone = 2 }; void SetStorage(const std::string &dir) { time_t t;