aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/foregroundtaskexecutor.h
blob: 6e92c03c3148911ed6743673eba35cf3efc22e9e (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
25
26
27
28
29
30
31
32
33
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "isequencedtaskexecutor.h"
#include <atomic>

namespace vespalib {

/**
 * Class to run multiple tasks in parallel, but tasks with same
 * id has to be run in sequence.
 *
 * Currently, this is a dummy version that runs everything in the foreground.
 */
class ForegroundTaskExecutor : public ISequencedTaskExecutor
{
public:
    using ISequencedTaskExecutor::getExecutorId;

    ForegroundTaskExecutor();
    ForegroundTaskExecutor(uint32_t threads);
    ~ForegroundTaskExecutor() override;

    ExecutorId getExecutorId(uint64_t componentId) const override;
    void executeTask(ExecutorId id, Executor::Task::UP task) override;
    void sync_all() override;
    void setTaskLimit(uint32_t taskLimit) override;
    ExecutorStats getStats() override;
private:
    std::atomic<uint64_t> _accepted;
};

} // namespace search