Is your feature request related to a problem? Please describe.
On the file /src/robot/Communication/Protocol.hpp, function void recv_frame(const atomic_bool&, function<void(GlobalFrame)>: the ETHERNET communication creates N detached threads on all the lifetime of the communication.
At the end, when we want to stop it, the atomic_bool& is set to false and threads would exit, but only when they receive a frame on the associate socket (in order to exit the UDP blocking recv_from function).
In order to avoid sending an ampty frame to all UDP connections but only one, a for(thread t : pool) { pthread_cancel(t); } loop is used at the very end of the program; it isn't a dangerous feature because it does not compromise the communication itself or the core.
I would like a better ending function to stop all threads properly.
Describe the solution you'd like
Create N receiving threads
When a reception ends, a AbstractSerialProtocol<P>::ReceptionAborted exception is thrown so we need to catch it (maybe using the std::exception_ptr object
Send an empty frame at all the other working threads to force them exit their receiving blocking function
Is your feature request related to a problem? Please describe. On the file
/src/robot/Communication/Protocol.hpp
, functionvoid recv_frame(const atomic_bool&, function<void(GlobalFrame)>
: the ETHERNET communication createsN
detached threads on all the lifetime of the communication.At the end, when we want to stop it, the
atomic_bool&
is set to false and threads would exit, but only when they receive a frame on the associate socket (in order to exit the UDP blockingrecv_from
function).In order to avoid sending an ampty frame to all UDP connections but only one, a
for(thread t : pool) { pthread_cancel(t); }
loop is used at the very end of the program; it isn't a dangerous feature because it does not compromise the communication itself or the core.I would like a better ending function to stop all threads properly.
Describe the solution you'd like
N
receiving threadsAbstractSerialProtocol<P>::ReceptionAborted
exception is thrown so we need to catch it (maybe using thestd::exception_ptr
object