MCPcopy Create free account
hub / github.com/e2wugui/zeze / uiThreadScheduleTime

Function uiThreadScheduleTime

cxx/utils.cpp:29–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 void uiThreadScheduleTime(int ms)
30 {
31 std::vector<Runnable> tmp;
32 {
33 std::lock_guard<std::mutex> l(uithread::mutex);
34 tmp.swap(uithread::tasks);
35 }
36 auto rt = std::chrono::high_resolution_clock::now();
37 auto timeouted = false;
38 std::vector<Runnable> unrun;
39 unrun.reserve(tmp.size());
40 for (auto& task : tmp) {
41 if( timeouted)
42 {
43 unrun.push_back(task);
44 }
45 else
46 {
47 task();
48 auto dt = std::chrono::high_resolution_clock::now() - rt;
49 auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(dt).count();
50 timeouted = elapsed >= ms;
51 }
52 }
53 if(!unrun.empty()) {
54 std::lock_guard<std::mutex> l(uithread::mutex);
55 uithread::tasks.insert(uithread::tasks.begin(), unrun.begin(), unrun.end());
56 }
57 }
58
59 void uiThreadScheduleCount(size_t count)
60 {

Callers

nothing calls this directly

Calls 7

sizeMethod · 0.65
swapMethod · 0.45
reserveMethod · 0.45
countMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected