MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / LogThreadFunc

Function LogThreadFunc

Source/Tools/FEXServer/Logger.cpp:57–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void LogThreadFunc() {
58 fasio::poll_reactor Reactor;
59
60 auto Pipe = fasio::posix_descriptor {Reactor, LogClientQueuePipe[0]};
61 fextl::vector<fasio::posix_descriptor> Clients;
62
63 // Wait for AppendLogFD to send file descriptors over LogClientQueuePipe.
64 // When data becomes ready, we read the FD and register it to the reactor.
65 Pipe.async_wait([&](fasio::error ec) {
66 if (ec != fasio::error::success) {
67 return fasio::post_callback::stop_reactor;
68 }
69
70 int ReceivedFD;
71 read(Pipe.FD, &ReceivedFD, sizeof(ReceivedFD));
72
73 // Register client and set up read callback
74 Clients.emplace_back(Reactor, ReceivedFD);
75 Clients.back().async_wait([&Clients, ReceivedFD](fasio::error ec) {
76 if (ec != fasio::error::success) {
77 std::iter_swap(std::find_if(Clients.begin(), Clients.end(), [=](auto& desc) { return desc.FD == ReceivedFD; }), std::prev(Clients.end()));
78 Clients.pop_back();
79 return fasio::post_callback::drop;
80 }
81
82 HandleLogData(ReceivedFD);
83 return fasio::post_callback::repeat;
84 });
85
86 return fasio::post_callback::repeat;
87 });
88
89 Reactor.run();
90}
91
92void StartLogThread() {
93 pipe2(LogClientQueuePipe, 0);

Callers

nothing calls this directly

Calls 6

HandleLogDataFunction · 0.85
async_waitMethod · 0.80
readFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected