blob: 699fd8e27a0bc0016bb8691febc0ffd4bfcc3ce8 (
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
34
35
36
37
38
39
40
41
42
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "runnable.h"
#include <vector>
namespace vespalib {
/**
* Interface used to separate the ownership and deployment of a
* collection of threads cooperating to perform a partitioned
* operation in parallel.
**/
struct ThreadBundle {
/**
* The size of the thread bundle is defined to be the maximum
* number of runnables that can be performed in parallel by the
* run function.
*
* @return size of this thread bundle
**/
virtual size_t size() const = 0;
/**
* Performs all the given runnables in parallel and waits for
* their completion. This function cannot be called with more
* targets than the size of this bundle.
**/
virtual void run(const std::vector<Runnable*> &targets) = 0;
/**
* Empty virtual destructor to enable subclassing.
**/
virtual ~ThreadBundle() {}
// a thread bundle that can only run things in the current thread.
static ThreadBundle &trivial();
};
} // namespace vespalib
|