Skip to content

Commit 5788494

Browse files
committed
* fix
1 parent 54487e8 commit 5788494

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

ReadMe.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
一个简单的示例, 在 reader 进程中执行 writer 进程里的函数
44
(该示例未必能成功执行, 因为可能运行于容器 (参见 docker `--tmpfs` 参数) 等权限受限的环境中):
55

6-
<https://github.com/shynur/ipcator/blob/4c8943e5fdaf028f85c820d9b33a836e40ffd41c/src/ipc-writer.cpp#L1-L21>
7-
<https://github.com/shynur/ipcator/blob/4c8943e5fdaf028f85c820d9b33a836e40ffd41c/src/ipc-reader.cpp#L1-L13>
6+
<https://github.com/shynur/ipcator/blob/e949c1d534304fbbac9ba286a6ebbfee8058c539/src/ipc-writer.cpp#L1-L23>
7+
<https://github.com/shynur/ipcator/blob/e949c1d534304fbbac9ba286a6ebbfee8058c539/src/ipc-reader.cpp#L1-L13>
88

99
你可自己手动编译执行; 也可根据 [测试双进程间的通信](#测试双进程间的通信) 的提示,
1010
将以上两段代码分别填到 [`src`](./src/) 目录下的 `ipc-*.cpp` 文件中,
@@ -30,7 +30,7 @@ git clone -b master --single-branch --recurse-submodule https://github.com/shynu
3030

3131
- Doxygen, Graphviz.
3232

33-
- `g++-10` (上至 `g++-15`), 或 `clang++-16` (上至 `clang++-19`).
33+
- `g++-10` (上至 `g++-15`), 或 `clang++-16` (上至 `clang++-20`).
3434

3535
- 直接执行 `make print-vars`, 不飘红就行; 否则, 根据提示设置正确的 编译器 和 C++ 标准. <br />
3636
例如, 在我的机器上有报错: `g++: error: unrecognized command line option ‘-std=c++26’; did you mean ‘-std=c++2a’?`,

include/ipcator.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ struct ShM_Reader {
16671667
}
16681668
auto& operator*() const { return *this->operator->(); }
16691669
#ifdef IPCATOR_USED_BY_SEER_RBK
1670-
auto get_cnt_ref() const { return this->shm.use_count(); }
1670+
auto cnt_ref_shm() const { return this->shm.use_count(); }
16711671
#endif
16721672
};
16731673
@@ -1682,16 +1682,16 @@ struct ShM_Reader {
16821682
auto gc_[[gnu::cold]]() noexcept {
16831683
return std::erase_if(
16841684
this->cache,
1685-
[](const auto pshm)
1685+
[](const auto& shm)
16861686
#ifdef __cpp_static_call_operator
16871687
static
16881688
#endif
16891689
{
16901690
return
16911691
#if __cplusplus <= 201703L
1692-
pshm->unique()
1692+
shm.unique()
16931693
#else
1694-
pshm->use_count() == 1
1694+
shm.use_count() == 1
16951695
#endif
16961696
;
16971697
}

src/ipc-writer.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ using namespace literals;
33

44
int shared_fn(int n) { return 2 * n + 1; } // 要传递的函数.
55
int main(int, const char *const av[]) {
6-
#if true // 或修改为 false.
7-
Monotonic_ShM_Buffer
8-
#else
9-
ShM_Pool<false>
10-
#endif
11-
shm_allocator;
6+
auto shm_allocator = Monotonic_ShM_Buffer/* 或 ShM_Pool<false> 或 ShM_Pool<true> */{};
127
const auto size_fn = std::stoul([&] { const auto p = popen(("echo print\\(0x`nm -SC "s + av[0] + " | grep ' shared_fn(int)$' - | awk -F' ' '{print $2}'`\\) | python3").c_str(), "r"); char buf[4]; fgets(buf, sizeof buf, p); return std::string{buf}; }());
138
const auto block = (char *)shm_allocator.allocate(size_fn); // 向 buffer 申请内存块.
149
for (const auto i : std::views::iota(0u, size_fn))

0 commit comments

Comments
 (0)