96#include "cppzmqzoltanext/czze_export.h"
143 explicit actor_t(zmq::context_t& context);
238 bool stop(std::chrono::milliseconds timeout = std::chrono::milliseconds{-1});
245 zmq::socket_t&
socket() noexcept {
return _parent_socket; }
277 static constexpr std::chrono::milliseconds DEFAULT_DESTRUCTOR_TIMEOUT{100};
283 struct SharedExceptionState {
284 std::mutex exception_mutex;
285 std::exception_ptr saved_exception;
300 static void execute(actor_fn_t func, std::unique_ptr<zmq::socket_t> socket,
301 std::shared_ptr<SharedExceptionState> exception_state)
noexcept;
312 std::string bind_to_unique_address();
314 zmq::socket_t _parent_socket;
315 std::unique_ptr<zmq::socket_t> _child_socket;
316 std::shared_ptr<SharedExceptionState> _exception_state;
319 std::chrono::milliseconds _timeout_on_destructor{DEFAULT_DESTRUCTOR_TIMEOUT};
std::function< bool(zmq::socket_t &)> actor_fn_t
Alias for a function type used to define actor behaviors.
Class that implements the Actor pattern using ZMQ PAIR sockets.
bool is_stopped() const noexcept
Checks if the actor thread was stopped.
bool is_started() const noexcept
Checks if the actor thread was started.
actor_t(actor_t const &)=delete
Copy constructor is deleted.
zmq::socket_t & socket() noexcept
Gets the parent socket for external communication.
actor_t & operator=(actor_t const &)=delete
Copy assignment operator is deleted.
std::chrono::milliseconds get_destructor_timeout() const noexcept
Gets the current timeout value used in the destructor.
void set_destructor_timeout(std::chrono::milliseconds timeout) noexcept
Sets the timeout value used in the destructor.