sundstei / retlang

Message passing based concurrency library
2 stars 1 forks source link

Channel registers subscriptions on the fiber, this ties subscriptions to lifetime of the fiber instead of the channel #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Not sure if this is an issue or just different ways of using Retlang but I 
wanted to bring it to your attention.

Previous to the introduction of ISubscriptionRegistry and related changes, any 
subscriptions to a Channel would only be held by the Channel. We relied on this 
behavior to avoid having to unsubscribe/dispose any subscriptions to a Channel 
as the lifetime of the Channel and the objects that were subscribing to it were 
generally tied together.

With the current behavior all subscriptions to a Channel are registered on the 
fiber (via ISubscriptionsRegistry) and so they will be held for the lifetime of 
the fiber or until we unsubscribe/dispose them.

Obviously, the answer is to ensure we unsubscribe/dispose all our subscriptions 
but it was very convenient for us to not have to.

I've worked around the problem by simply removing the RegesterSubscription line 
from Channel.

Original issue reported on code.google.com by leafgarland on 16 May 2011 at 11:45

GoogleCodeExporter commented 8 years ago
The reason this was added was so that subscriptions are properly cleaned up 
with a Fiber is disposed.  Before this change, it was not the case.

However, I can see how this can be more work, at least in the case of temporary 
channels.  In the future I will take a look and see if there is a cleaner way.

Original comment by graham.m...@gmail.com on 17 May 2011 at 4:23

GoogleCodeExporter commented 8 years ago
I'm planing to use temporary channels for streaming fileIO and probably socket 
stream.
"lifetime of the Channel and the objects that were subscribing to it were 
generally tied together"- will be appreciated I guess. Otherwise, I need to 
insure to clean any unused channels together with file handlers etc. ?

Original comment by pip...@gmail.com on 15 Feb 2012 at 2:24