blob: b2b15ded2745783f20eb221cd20b58ad880af482 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchlib/common/sequencedtaskexecutor.h>
#include <vespa/vespalib/util/lambdatask.h>
#include <atomic>
using search::SequencedTaskExecutor;
using ExecutorId = search::ISequencedTaskExecutor::ExecutorId;
int main(int argc, char *argv[]) {
unsigned long numTasks = 1000000;
unsigned numThreads = 4;
std::atomic<long> counter(0);
if (argc > 1)
numTasks = atol(argv[1]);
if (argc > 2)
numThreads = atoi(argv[2]);
auto executor = SequencedTaskExecutor::create(numThreads);
for (unsigned long tid(0); tid < numTasks; tid++) {
executor->executeTask(ExecutorId(tid%numThreads), vespalib::makeLambdaTask([&counter] { counter++; }));
}
return 0;
}
|