|
Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
|
Where the CLI server's commands reach a thread that owns some state (the main thread, or a venue's order gateway), and where that thread's answers come back. More...
#include <cli/cli_endpoint.hpp>
Public Member Functions | |
| CliEndpoint (std::string name={}) | |
| CliEndpoint (const CliEndpoint &)=delete | |
| CliEndpoint & | operator= (const CliEndpoint &)=delete |
| const std::string & | name () const noexcept |
| How the CLI addresses it, /-separated from the venue down: cme/<segment>. | |
| void | set_name (std::string name) |
| Before the endpoint is given to the CLI server. | |
| template<typename Handler> | |
| void | serve (Handler &&handler) |
| Owner thread. | |
| bool | post (const Command &command) |
| CLI server thread. False, posting nothing, while busy(). | |
| bool | busy () const noexcept |
| CLI server thread. | |
| template<typename OnReply> | |
| void | take_replies (OnReply &&on_reply) |
| CLI server thread. | |
Static Public Attributes | |
| static constexpr uint32_t | MAX_IN_FLIGHT = 16 |
| static constexpr uint32_t | MAX_REPLY_TEXT = 4096 |
| A longer reply is cut, ending in "...". | |
Where the CLI server's commands reach a thread that owns some state (the main thread, or a venue's order gateway), and where that thread's answers come back.
Two lock-free slick::queues, one each way. The CLI server thread is the only one that posts and takes replies, the owner thread the only one that serves. post() refuses while MAX_IN_FLIGHT commands are unanswered, so neither ring, lossy when lapped, is lapped.
The owner calls serve() from its loop. With nothing waiting it is one acquire load.
Definition at line 87 of file cli_endpoint.hpp.
|
inlineexplicit |
Definition at line 93 of file cli_endpoint.hpp.
References name().
Referenced by CliEndpoint(), and operator=().
|
delete |
References CliEndpoint().
|
inlinenodiscardnoexcept |
CLI server thread.
MAX_IN_FLIGHT commands posted and not yet answered through take_replies(), however long ago: one more would lap the inbox.
Definition at line 134 of file cli_endpoint.hpp.
References MAX_IN_FLIGHT.
Referenced by post().
|
inlinenodiscardnoexcept |
How the CLI addresses it, /-separated from the venue down: cme/<segment>.
Definition at line 98 of file cli_endpoint.hpp.
Referenced by CliEndpoint(), and set_name().
|
delete |
References CliEndpoint().
|
inlinenodiscard |
CLI server thread. False, posting nothing, while busy().
Definition at line 121 of file cli_endpoint.hpp.
References busy().
|
inline |
Owner thread.
Runs bool handler(const Command &, std::string &text) on each command waiting, logs what it said and posts text back, OK when the handler returned true.
Definition at line 106 of file cli_endpoint.hpp.
References slick::sim::FAILED, slick::sim::cli::log_level(), and slick::sim::OK.
Referenced by main().
|
inline |
Before the endpoint is given to the CLI server.
Definition at line 100 of file cli_endpoint.hpp.
References name().
|
inline |
CLI server thread.
Runs on_reply(uint64_t ticket, CliStatus, std::string_view) on each reply waiting.
Definition at line 139 of file cli_endpoint.hpp.
|
staticconstexpr |
Definition at line 89 of file cli_endpoint.hpp.
Referenced by busy().
|
staticconstexpr |
A longer reply is cut, ending in "...".
Definition at line 91 of file cli_endpoint.hpp.