JuliaLang/julia — pull request #1760 by WestleyArgentum (2012-12-14 19:34:15+00:00)
Title: "signaling" through remote references

Remote references, in a very basic and intuitive way, give a user the ability to retrieve the result of a computation. I think, however, they fit into a larger pattern of returning information, independent of any actual value. Basically, sometimes the fact that something is done or has happened is the "value" that I want.

I think of them in terms of systems I've used, like windows handles (except that anyone can start using Julia's RemoteRef without first googling their way through ancient and cryptic msdn documentation).

Windows handles start as event notifications. You can set one up and wait for it while another process does some work and then "signals" via the handle that they are done. On top of that you can add some way of sending data back and forth, but this makes using them frustrating because everyone and their mother has a different function for retrieving your result.

Julia (well, remote references in general) has (have) flipped the problem around. Fundamental is the idea that you want some result back. It seems to me, however, that there should still be a clean way of using remote references to signal that something has happened, even if you don't want to return a value.

I could be wrong, or even have missed that this functionality is already supported... but I see a use case even in julia-web-base:

In the web base a tcp connection is set up and a callback is registered for when a message comes in. After that a RemoteRef to the current process is made and waited on. When a message comes in the callback does some processing and returns a result through the remote ref. That result is taken, operated on, and triggers a response, etc.

I think it's easy to imagine a situation where the callback makes a complex set of changes that cannot be easily expressed as a single return value (well, short of returning the whole state of an application). In this case the callback could simply signal that it was done and the thing waiting could tell some systems to update (or whatever).

Thoughts? Criticisms?