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

Function processTest

POSIX/demo/demo.cpp:283–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void processTest() {
284 constexpr auto processCount = 2;
285 pid_t processHandles[processCount] = {0};
286 for (int &processHandle : processHandles) {
287 auto pid = fork();
288 // this is child
289 if (pid <= 0) {
290 execl("process", "process", nullptr);
291 perror("execl"); // execl doesn't return unless there is a problem
292 exit(1);
293 } else {
294 processHandle = pid;
295 }
296 }
297
298 for (int &processHandle : processHandles) {
299 printf("Waiting for child %d ...\n", processHandle);
300 auto pid = waitpid(processHandle, nullptr, 0);
301 printf("Child quit pid: %d\n", pid);
302 }
303
304 auto mmkv = MMKV::mmkvWithID("process_test", MMKV_MULTI_PROCESS);
305 cout << "total count of process_test: " << mmkv->count() << endl;
306}
307
308void testInterProcessLock() {
309 //auto mmkv = MMKV::mmkvWithID("TestInterProcessLock", MMKV_MULTI_PROCESS);

Callers 1

mainFunction · 0.70

Calls 2

mmkvWithIDFunction · 0.85
countMethod · 0.45

Tested by

no test coverage detected