MCPcopy Create free account
hub / github.com/alibaba/MNN / run

Method run

test/core/ThreadPoolTest.cpp:19–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17public:
18 virtual ~ThreadPoolTest() = default;
19 virtual bool run(int precision) {
20 std::vector<std::thread> threads;
21 for (int i = 0; i < 10; ++i) {
22 threads.emplace_back([i]() {
23 MNN::ThreadPool* threadPool = nullptr;
24 MNN::ThreadPool::init(10 - i, 0, threadPool);
25 // initializer
26 auto workIndex = threadPool->acquireWorkIndex();
27 FUNC_PRINT(workIndex);
28 threadPool->active();
29 ThreadPool::TASK task = std::make_pair([](int index) {
30 FUNC_PRINT(index);
31 std::this_thread::yield();
32 }, 10);
33 threadPool->enqueue(&task, workIndex);
34 threadPool->deactive();
35 threadPool->releaseWorkIndex(workIndex);
36 });
37 }
38 for (auto& t : threads) {
39 t.join();
40 }
41 MNN::ThreadPool::destroy();
42 return true;
43 }
44};
45
46MNNTestSuiteRegister(ThreadPoolTest, "core/threadpool");

Callers

nothing calls this directly

Calls 8

initFunction · 0.85
acquireWorkIndexMethod · 0.80
activeMethod · 0.80
deactiveMethod · 0.80
releaseWorkIndexMethod · 0.80
joinMethod · 0.80
destroyFunction · 0.50
enqueueMethod · 0.45

Tested by

no test coverage detected