Closed AkiraMiyakoda closed 6 months ago
The primary purpose of SocketRef
before being an extractor is to remove the clone method from the inner Arc<Socket>
the main reason is to protect the user from memory leaks. If the user for instance builds a HashMap<String, Arc<SocketRef>>
and doesn't remove the socket from the hashmap when it is closed, the socket is never freed.
However it is possible to keep this behaviour as you said by creating an Arc<SocketRef>
. I'm going to do some research on this to be sure that never freeing the socket doesn't create a bad state in the socketio model.
Motivation
I sometimes find it useful to pass
SocketRef
across threads. However, I need to useArc<SocketRef>
to do that despite thatSocketRef
itself is essentially anArc
.SocketIo
which also wrapsArc
already hasclone
method. So I believe that we can haveSocketRef::clone
too.Solution
This PR implements the
Clone
trait forSocketRef
likeSocketIo
.