MCPcopy Create free account
hub / github.com/alibaba/async_simple / delayedTask

Function delayedTask

benchmarks/Uthread.bench.cpp:27–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <class Func>
27void delayedTask(Executor* ex, Func&& func, std::size_t ms) {
28 std::thread(
29 [f = std::move(func), ms](Executor* ex) {
30 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
31 ex->schedule(std::move(f));
32 },
33 ex)
34 .detach();
35}
36
37void Uthread_switch(benchmark::State& state) {
38 async_simple::executors::SimpleExecutor executor(10);

Callers 5

TEST_FFunction · 0.85
Uthread_switchFunction · 0.85
Uthread_asyncFunction · 0.85
Uthread_awaitFunction · 0.85
Uthread_collectAllFunction · 0.85

Calls 3

threadClass · 0.85
detachMethod · 0.45
scheduleMethod · 0.45

Tested by 1

TEST_FFunction · 0.68