Note: this needs the joe/feature/private-event-loops2 branch branch of later.
In this example, the websocket is created and closed, and driven from a private event loop. It calls run_now() until the websocket's has readyState()==3. If the ws object is removed and then a GC happens, the object is not garbage collected. The event loop needs to be run one more time before the GC occurs.
Note: this needs the joe/feature/private-event-loops2 branch branch of later.
In this example, the websocket is created and closed, and driven from a private event loop. It calls
run_now()
until the websocket's hasreadyState()==3
. If thews
object is removed and then a GC happens, the object is not garbage collected. The event loop needs to be run one more time before the GC occurs.This happens because
scheduleIncoming()
is always called right afterwsPoll()
, even if thatwsPoll()
call changes the readyState to 3:https://github.com/rstudio/websocket/blob/ccc03d59868b3ced956d54bd22dc4e89376dd207/R/websocket.R#L240-L247