TensorFlow Serving C++ API Documentation
tensorflow_serving
util
threadpool_executor.h
1
/* Copyright 2016 Google Inc. All Rights Reserved.
2
3
Licensed under the Apache License, Version 2.0 (the "License");
4
you may not use this file except in compliance with the License.
5
You may obtain a copy of the License at
6
7
http://www.apache.org/licenses/LICENSE-2.0
8
9
Unless required by applicable law or agreed to in writing, software
10
distributed under the License is distributed on an "AS IS" BASIS,
11
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
See the License for the specific language governing permissions and
13
limitations under the License.
14
==============================================================================*/
15
16
#ifndef TENSORFLOW_SERVING_UTIL_THREADPOOL_EXECUTOR_H_
17
#define TENSORFLOW_SERVING_UTIL_THREADPOOL_EXECUTOR_H_
18
19
#include <functional>
20
21
#include "tensorflow/core/lib/core/threadpool.h"
22
#include "tensorflow/core/platform/env.h"
23
#include "tensorflow_serving/util/executor.h"
24
25
namespace
tensorflow {
26
namespace
serving {
27
28
// An executor which uses a pool of threads to execute the scheduled closures.
29
class
ThreadPoolExecutor
:
public
Executor
{
30
public
:
31
// Constructs a threadpool that has 'num_threads' threads with specified
32
// 'thread_pool_name'. Env is used to start the thread.
33
//
34
// REQUIRES: num_threads > 0.
35
ThreadPoolExecutor
(Env* env,
const
string
& thread_pool_name,
int
num_threads);
36
37
// Waits until all scheduled work has finished and then destroy the set of
38
// threads.
39
~
ThreadPoolExecutor
()
override
;
40
41
void
Schedule
(std::function<
void
()> fn)
override
;
42
43
private
:
44
thread::ThreadPool thread_pool_;
45
46
TF_DISALLOW_COPY_AND_ASSIGN(
ThreadPoolExecutor
);
47
};
48
49
}
// namespace serving
50
}
// namespace tensorflow
51
52
#endif
// TENSORFLOW_SERVING_UTIL_THREADPOOL_EXECUTOR_H_
tensorflow::serving::Executor
Definition:
executor.h:27
tensorflow::serving::ThreadPoolExecutor
Definition:
threadpool_executor.h:29
tensorflow::serving::ThreadPoolExecutor::Schedule
void Schedule(std::function< void()> fn) override
Definition:
threadpool_executor.cc:29
Generated by
1.9.1