mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
fix some bugs
This commit is contained in:
parent
e3c8f8edc1
commit
57a62bc073
@ -112,7 +112,7 @@ struct chunk_info_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ipc::byte_t* at(std::size_t chunk_size, ipc::storage_id_t id) noexcept {
|
ipc::byte_t* at(std::size_t chunk_size, ipc::storage_id_t id) noexcept {
|
||||||
assert(id >= 0);
|
if (id < 0) return nullptr;
|
||||||
return chunks_mem() + (chunk_size * id);
|
return chunks_mem() + (chunk_size * id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -137,13 +137,11 @@ auto& chunk_storages() {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static ipc::unordered_map<std::size_t, chunk_t> chunk_s;
|
thread_local ipc::unordered_map<std::size_t, chunk_t> chunk_s;
|
||||||
return chunk_s;
|
return chunk_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_info_t *chunk_storage_info(std::size_t chunk_size) {
|
chunk_info_t *chunk_storage_info(std::size_t chunk_size) {
|
||||||
static std::mutex lock;
|
|
||||||
IPC_UNUSED_ std::lock_guard<std::mutex> guard {lock};
|
|
||||||
return chunk_storages()[chunk_size].get_info(chunk_size);
|
return chunk_storages()[chunk_size].get_info(chunk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -128,9 +128,10 @@ void test_sr(char const * name, int s_cnt, int r_cnt) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT_TRUE((i >= 0) && (i < (int)data_set__.get().size()));
|
ASSERT_TRUE((i >= 0) && (i < (int)data_set__.get().size()));
|
||||||
if (data_set__.get()[i] != got) {
|
auto const &data_set = data_set__.get()[i];
|
||||||
|
if (data_set != got) {
|
||||||
printf("data_set__.get()[%d] != got, size = %zd/%zd\n",
|
printf("data_set__.get()[%d] != got, size = %zd/%zd\n",
|
||||||
i, data_set__.get()[i].size(), got.size());
|
i, data_set.size(), got.size());
|
||||||
EXPECT_TRUE(false);
|
EXPECT_TRUE(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ TEST(IPC, 1vN) {
|
|||||||
//test_sr<relat::single, relat::multi , trans::unicast >("smu", 1, MultiMax);
|
//test_sr<relat::single, relat::multi , trans::unicast >("smu", 1, MultiMax);
|
||||||
//test_sr<relat::multi , relat::multi , trans::unicast >("mmu", 1, MultiMax);
|
//test_sr<relat::multi , relat::multi , trans::unicast >("mmu", 1, MultiMax);
|
||||||
test_sr<relat::single, relat::multi , trans::broadcast>("smb", 1, MultiMax);
|
test_sr<relat::single, relat::multi , trans::broadcast>("smb", 1, MultiMax);
|
||||||
test_sr<relat::multi , relat::multi , trans::broadcast>("mmb", 1, MultiMax);
|
//test_sr<relat::multi , relat::multi , trans::broadcast>("mmb", 1, MultiMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(IPC, Nv1) {
|
TEST(IPC, Nv1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user