What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
bug fix
What is the current behavior? (You can also link to an open issue here)
fixes #107
The cause was the assignment of _socketProcess happening async, meaning that if disconnect or destroy was called before that promise had resolved, then it would look like connect had never been called, and the cleanup would be skipped
What is the new behavior (if this is a feature change)?
There are two parts here.
1) _isDisconnecting is used by disconnect to skip the call to the threads connect method if disconnect is called while the thread is being created. Once the thread is created, disconnect previously operated as expected
2) _creatingSocket is used by destroy, so that it can wait for the thread creation to complete before attempting to destroy the thread. in the future, maybe this creation can be abortable, but that will require changes in threadedclass
bug fix
fixes #107
The cause was the assignment of
_socketProcess
happening async, meaning that ifdisconnect
ordestroy
was called before that promise had resolved, then it would look likeconnect
had never been called, and the cleanup would be skippedThere are two parts here. 1)
_isDisconnecting
is used bydisconnect
to skip the call to the threadsconnect
method ifdisconnect
is called while the thread is being created. Once the thread is created,disconnect
previously operated as expected 2)_creatingSocket
is used bydestroy
, so that it can wait for the thread creation to complete before attempting to destroy the thread. in the future, maybe this creation can be abortable, but that will require changes in threadedclassOnly given a very light synthetic test so far.