MCPcopy Create free account
hub / github.com/Tencent/MMKV / main

Function main

POSIX/demo/TestInterProcessLock.cpp:103–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103int main() {
104 locale::global(locale(""));
105 wcout.imbue(locale(""));
106
107 string rootDir = "/tmp/mmkv";
108 MMKV::initializeMMKV(rootDir);
109
110 auto processID = getpid();
111 cout << "TestInterProcessLock: " << processID << " started\n";
112
113// auto fd3 = open("/tmp/mmkv/TestInterProcessLock2.file", O_RDWR | O_CREAT | O_CLOEXEC, S_IRWXU);
114// FileLock flock3(fd3);
115//
116// auto ptr = ::mmap(nullptr, DEFAULT_MMAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd3, 0);
117// printf("mmap fd %d to %p\n", fd3, ptr);
118//
119// printf("trying flock.try_lock %d\n", fd3);
120// flock3.try_lock(ExclusiveLockType, nullptr);
121// printf("trying flock.lock %d\n", fd3);
122// flock3.lock(ExclusiveLockType);
123// printf("finish flock.lock %d\n", fd3);
124
125 auto ret = threadTest();
126 cout << "TestInterProcessLock: " << (ret ? "pass" : "failed") << endl;
127 cout << "TestInterProcessLock: " << processID << " ended\n";
128
129 return 0;
130}

Callers

nothing calls this directly

Calls 1

threadTestFunction · 0.70

Tested by

no test coverage detected