14 #ifndef TSA_PLATFORM_SOCKET__INCLUDED 15 #define TSA_PLATFORM_SOCKET__INCLUDED 23 #include "TSATypeDef.h" 24 #include "TSAStreams.h" 26 #include "TSAIntraday.h" 27 #include "TSAPlatformMsg.h" 49 bool test__no_dispatch_to_strategy =
false;
50 bool test__no_thread =
false;
52 static std::atomic<int> s_signal_value;
57 message::type message_type;
59 std::vector<strategy*> m_strategies;
60 mutable std::mutex m_mutex;
61 mutable std::mutex m_mutex_handle_exception;
67 bool m_has_already_run =
false;
68 bool m_message_pump_is_running =
false;
69 bool m_is_connected =
false;
70 bool m_strategies_are_running =
false;
72 mutable std::mutex m_shutdown_request_mutex;
73 bool m_shutdown_requested =
false;
75 enum class shutdown_type {
77 shutdown_with_exception
79 shutdown_type m_shutdown_type = shutdown_type::normal_shutdown;
80 void request_shutdown(shutdown_type type,
const std::string& exception_what =
"");
83 bool is_running(
void)
const;
84 bool is_connected(
void)
const;
85 void set_connected(
bool);
90 void on_strategy_exception(
const strategy*,
const std::exception&);
97 void init_strategies(
void);
99 size_t strategy_count(
void)
const;
102 void remove_strategy_ref(
strategy*);
103 bool has_valid_strategy__no_lock(
void)
const;
108 strategy* strategy_ptr(
int pos)
const;
113 virtual void send(net::message&) = 0;
115 virtual void on_message(net::message&);
119 virtual void on_connection_lost(
void);
122 virtual bool wait_message(net::message&,
int usec_timeout) = 0;
125 void dispatch_message(net::message&);
127 void send_ctrl_c_exit_command_to_all_strategies(
void);
132 std::mutex m_mutex__RPC_values;
133 std::map<int, std::string> m_RPC_return_vals;
134 int m_RPC_token_count = 1;
135 int RPC_next_token(
void);
137 bool RPC(
const json& call_definition,
json& response,
int timeout_millisec = 6000);
138 void RPC__except(
const json& call_definition,
json& response,
int timeout_millisec = 6000);
140 int send__RPC_request(
const json& call_def);
141 bool fetch_RPC_result(
int token,
std::string& return_value,
int timeout_millisec = 6000);
143 void RPC__set_return_value(
int token,
const std::string& value);
144 bool RPC__return_value_exists(
int token);
145 bool RPC__return_value_exists__no_lock(
int token);
152 std::thread m_message_pump_thread;
153 void thread_fn__message_pump(
void);
154 bool m_stop_msg_pump_thread =
false;
156 std::thread m_command_line_thread;
157 void thread_fn__command_line(
void);
158 bool m_stop_command_line_thread =
false;
160 void start_message_pump_thread(
void);
162 void start_threads(
void);
164 void stop_threads(
void);
Namespace for the 'Trading System API' library.
Definition: original1.TSA3Core.cpp:20
Parent class for many library classes.
Definition: TSATypeDef.h:462
A class representing JSON objects.
Definition: TSAJSON.h:81
Class strategy represents a trading or investment strategy.
Definition: TSAStrategy.h:108
Definition: TSAPlatformSocket.h:46
int64_t identifier_t
type for ID's
Definition: TSATypeDef.h:117