MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / main

Function main

samples/render_graph/cross-process/main.cpp:14–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12extern int receiver_main(int argc, char* argv[]);
13
14int main(int argc, char* argv[])
15{
16 exec_name = (const char8_t*)argv[0];
17 if (argc == 1)
18 {
19 SKR_LOG_DEBUG(u8"exec_name: %s", exec_name);
20
21 const char8_t* provider_arguments[] = { u8"provider", u8"-1"};
22 auto provider = skr_run_process(exec_name,
23 provider_arguments, 2, u8"provider.log");
24 const auto provider_id = skr_get_process_id(provider);
25
26 skr::String providerIdString = skr::format(u8"{}", provider_id);
27 const char8_t* receiver_arguments[] = { u8"receiver", providerIdString.u8_str() };
28 auto receiver = skr_run_process(exec_name,
29 receiver_arguments, 2, u8"receiver.log");
30
31 auto provider_result = skr_wait_process(provider);
32 auto receriver_result = skr_wait_process(receiver);
33 return receriver_result + provider_result;
34 }
35 else
36 {
37 auto id = skr_get_current_process_id();
38 SKR_LOG_DEBUG(u8"exec_mode: %s, process id: %lld", argv[1], id);
39 auto is_receiver = (strcmp(argv[1], "receiver") == 0);
40
41 std::error_code ec = {};
42 if (!skr::filesystem::exists("./cross-proc", ec))
43 {
44 SKR_LOG_INFO(u8"subdir cross-proc not existed, create it");
45 skr::filesystem::create_directories(skr::filesystem::path("./cross-proc"), ec);
46 }
47
48 if (is_receiver)
49 return receiver_main(argc, argv);
50 else
51 return provider_main(argc, argv);
52 }
53}

Callers

nothing calls this directly

Calls 9

existsClass · 0.85
receiver_mainFunction · 0.85
provider_mainFunction · 0.85
skr_run_processFunction · 0.50
skr_get_process_idFunction · 0.50
formatFunction · 0.50
skr_wait_processFunction · 0.50
u8_strMethod · 0.45

Tested by

no test coverage detected