KiCad PCB EDA Suite
|
Spin up a thread to send messages via a socket. More...
Public Member Functions | |
ASYNC_SOCKET_HOLDER () | |
~ASYNC_SOCKET_HOLDER () | |
bool | Send (int aService, const std::string &aMessage) |
Attempt to send a message if the thread is available. | |
Private Member Functions | |
void | worker () |
Actual task that sends data to the socket server. | |
Private Attributes | |
std::thread | m_thread |
std::pair< int, std::string > | m_message |
bool | m_messageReady |
std::mutex | m_mutex |
std::condition_variable | m_cv |
bool | m_shutdown |
Spin up a thread to send messages via a socket.
No message queuing, if a message is in flight when another is posted with Send(), the second is just dropped. This is a workaround for "non-blocking" sockets not always being non-blocking, especially on Windows. It is kept fairly simple and not exposed to the outside world because it should be replaced in a future KiCad version with a real message queue of some sort, and unified with the Kiway messaging system.
Definition at line 126 of file eda_dde.cpp.
|
inline |
Definition at line 129 of file eda_dde.cpp.
References HOSTNAME(), KICAD_PCB_PORT_SERVICE_NUMBER, m_thread, and worker().
|
inline |
Definition at line 149 of file eda_dde.cpp.
References m_cv, m_mutex, m_shutdown, and m_thread.
|
inline |
Attempt to send a message if the thread is available.
aService | is the port number (i.e. service) to send to. |
aMessage | is the message to send. |
Definition at line 175 of file eda_dde.cpp.
References m_cv, m_message, m_messageReady, and m_mutex.
|
inlineprivate |
Actual task that sends data to the socket server.
Definition at line 193 of file eda_dde.cpp.
References HOSTNAME(), m_cv, m_message, m_messageReady, m_mutex, and m_shutdown.
Referenced by ASYNC_SOCKET_HOLDER().
|
private |
Definition at line 293 of file eda_dde.cpp.
Referenced by Send(), worker(), and ~ASYNC_SOCKET_HOLDER().
|
private |
Definition at line 290 of file eda_dde.cpp.
|
private |
Definition at line 291 of file eda_dde.cpp.
|
mutableprivate |
Definition at line 292 of file eda_dde.cpp.
Referenced by Send(), worker(), and ~ASYNC_SOCKET_HOLDER().
|
private |
Definition at line 294 of file eda_dde.cpp.
Referenced by worker(), and ~ASYNC_SOCKET_HOLDER().
|
private |
Definition at line 289 of file eda_dde.cpp.
Referenced by ASYNC_SOCKET_HOLDER(), and ~ASYNC_SOCKET_HOLDER().