in reply to Coro::Channel, worker thread and timeout

If you want to cancel a certain Coro thread, you will need to find out what primitives Coro has for cancelling a (Coro) thread. Personally, I would not use the synchronous tcp_connect, but a version that returns a guard. That way, you can at least cancel the connect by resetting the guard.

Personally, I wouldn't use Coro explicitly but rather look at what AnyEvent provides as primitives to handle the socket multiplexing and cancellation.

Replies are listed 'Best First'.
Re^2: Coro::Channel, worker thread and timeout
by Marseille07 (Acolyte) on Sep 13, 2011 at 06:00 UTC
    It turned out tcp_connect returns a guard object unless it is in the void context, so I played with it a little bit -- unfortunately, it is not allowing me to get out of the timer call back and then proceed with the worker thread. I was hoping there is a way to do that, but maybe after the Anyevent->timer CB gets invoked, there is no way back to the while(1) loop -- which I think was strange but it may just be how it is.
Re^2: Coro::Channel, worker thread and timeout
by Marseille07 (Acolyte) on Sep 13, 2011 at 05:17 UTC
    Thank you, this is definitely a good point. I'll look into socket calls that utilizes a guard. Will post back with a result.