提交 b904480c 编写于 作者: S superjom

init read and write serivce

上级 b1ba69d1
......@@ -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<MemoryStorage *>(storage_.get())->StartReadService();
break;
case StorageBase::Mode::kWrite:
dynamic_cast<MemoryStorage *>(storage_.get())->StartWriteSerice();
break;
default:
break;
}
}
void IM::SetPersistDest(const std::string &path) {
CHECK(storage_->mutable_data()->dir().empty())
<< "duplicate set storage's path";
......
......@@ -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();
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册