Turi Create  4.0
unity_server.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 SFRAME_UNITY_SERVER_HPP
7 #define SFRAME_UNITY_SERVER_HPP
8 
9 #include <core/parallel/pthread_tools.hpp>
10 #include <core/util/blocking_queue.hpp>
11 #include "unity_server_options.hpp"
12 #include "unity_server_init.hpp"
13 
14 namespace turi {
15 // Forward declaration of classes
16 class toolkit_function_registry;
17 class toolkit_class_registry;
18 
19 class unity_server {
20  public:
21  typedef void(*progress_callback_type)(const std::string&);
22 
23  /**
24  * Constructor
25  */
26  unity_server(unity_server_options options);
27 
28  /**
29  * Start the server object
30  */
31  void start(const unity_server_initializer& server_initializer);
32 
33  /**
34  * Stop the server and cleanup state
35  */
36  void stop();
37 
38  /**
39  * Enable or disable log progress stream.
40  */
41  void set_log_progress(bool enable);
42  void set_log_progress_callback(progress_callback_type callback);
43 
44  private:
45  unity_server_options options;
46  toolkit_function_registry* toolkit_functions;
47  toolkit_class_registry* toolkit_classes;
48 
49  volatile progress_callback_type log_progress_callback = nullptr;
50 
51  turi::thread log_thread;
52  blocking_queue<std::string> log_queue;
53 
54 }; // end of class usenity_server
55 } // end of namespace turi
56 
57 #endif