Turi Create  4.0
graph_pylambda_master.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_LAMBDA_GRAPH_PYLAMBDA_MASTER_HPP
7 #define TURI_LAMBDA_GRAPH_PYLAMBDA_MASTER_HPP
8 
9 #include<core/system/lambda/graph_lambda_interface.hpp>
10 #include<core/system/lambda/worker_pool.hpp>
11 
12 namespace turi {
13 
14 namespace lambda {
15  /**
16  * \ingroup lambda
17  *
18  * Simple singleton object managing a worker_pool of graph lambda workers.
19  */
21  public:
22 
23  static graph_pylambda_master& get_instance();
24 
25  static void shutdown_instance();
26 
27  graph_pylambda_master(size_t nworkers = 8);
28 
29  inline size_t num_workers() { return m_worker_pool->num_workers(); }
30 
31  static void set_pylambda_worker_binary(const std::string& path) { pylambda_worker_binary = path; };
32 
33  inline std::shared_ptr<worker_pool<graph_lambda_evaluator_proxy>> get_worker_pool() {
34  return m_worker_pool;
35  }
36 
37  private:
38 
40 
41  graph_pylambda_master& operator=(graph_pylambda_master const&) = delete;
42 
43  private:
44  std::shared_ptr<worker_pool<graph_lambda_evaluator_proxy>> m_worker_pool;
45 
46  static std::string pylambda_worker_binary;
47  };
48 } // end lambda
49 } // end turicreate
50 
51 #endif