未验证 提交 b0911ecb 编写于 作者: S sneaxiy 提交者: GitHub

Add unique counter for shared memory used in DataLoader (#52976)

* fix ipc counter

* fix missing std::to_string
上级 1b5eba8a
......@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <sys/mman.h>
#include <atomic>
#include <random>
#include <string>
......@@ -34,12 +35,15 @@ namespace allocation {
std::string GetIPCName() {
static std::random_device rd;
static std::atomic<uint64_t> counter{0};
std::string handle = "/paddle_";
#ifdef _WIN32
handle += std::to_string(GetCurrentProcessId());
#else
handle += std::to_string(getpid());
#endif
handle += "_";
handle += std::to_string(counter.fetch_add(1));
handle += "_";
handle += std::to_string(rd());
return handle;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册