GemTalk / RemoteServiceReplication

MIT License
0 stars 4 forks source link

Connection should offer a subscriber interface instead of only #waitUntilClosed #103

Closed kurtkilpela closed 3 years ago

kurtkilpela commented 3 years ago

Connection's interface is less than ideal for certain use cases. You can call #waitUntilClosed in order to detect a closure of the Connection w/o sending a message. This is less than ideal since it causes the calling thread to hang until the Connection is closed. It would be nice if you could asynchronously monitor the state of the Connection.

It would be nice to register an action w/ the Connection to be evaluated (in a new thread) when the Connection is shut down.

addClosureEvent: aBlock
   "This method registers an action which is activated once the Connection has been closed.
   The action receives the Connection instance as an argument via #cull: and is evaluated in a new thread.
   The framework does not provide any Exception protection in the new thread."
rjsargent commented 3 years ago

"subscriber interface" / register to be notified when / etc. are the Announcements API.

kurtkilpela commented 3 years ago

While true, this does not take into account the Dolphin environment.

kurtkilpela commented 3 years ago

Actually, my understanding of Dolphin's support for Announcements was incorrect. It looks as though there is support for Announcements so I can just use Announcements assuming we move Announcements out of the Sparkle project and into a repo RSR can depend upon.

kurtkilpela commented 3 years ago

Pushed to development. Connection>>#waitUntilClose is now written in terms of an Announcement rather than storing a semaphore on the Connection.

Note, GemStone did not provide Object>>#initialize until a recent 3.7.0 build. GemStone's Announcer>>#initialize calls super initialize. This results in a DNU. You'll either need to implement Object>>#initialize or upgrade to a recent 3.7.0 in order to avoid the DNU.

See 2fb26466c92fdb7b89c1b4551a297eec9f0a1989