blob: bc89a9decacc6fc3723b3f9ec9b9635d9068798e (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <memory>
#include <functional>
namespace vespalib {
// Convenience macro used to create a function that can be used as an
// init function when creating an executor to inject a frame with the
// given name into the stack of all worker threads.
#define VESPA_THREAD_STACK_TAG(name) \
int name(::vespalib::Runnable &worker) { \
worker.run(); \
return 1; \
}
/**
* Interface implemented in order to be run by a Thread.
**/
struct Runnable {
using UP = std::unique_ptr<Runnable>;
using init_fun_t = std::function<int(Runnable&)>;
static int default_init_function(Runnable &target);
/**
* Entry point called by the running thread
**/
virtual void run() = 0;
/**
* Empty virtual destructor to enable subclassing.
**/
virtual ~Runnable() {}
};
} // namespace vespalib
|