I thought I'd follow up on my last technical post with a few extra details about the Marble pattern, despite the name of the article I mostly talked about the Wood pattern. I guess perhaps this is timely because the use of Promises to represent asynchronous operations is increasingly popular, but these notions are not really limited to context pattern, though promises do make for good examples.
So, what are the essential properties?
Wood:
Marble:
Again, using promises as an example (and I am not down on promises at all, they work great, but you don't have switch to the wood pattern universally just because you have async i/o)
In the marble pattern I can still write nice anonymous delegates if I choose, or I can provide a class or other handler, whatever is necessary. However I don't create one handler instance for every datum. I created one or more broker objects that handle the various stages of processing and coordinate some or all of the post steps.
From a memory perspective Marble is much more economical and of course it doesn't have the terrible property that I'm making lots of long lived objects. In the wood pattern everything ends up being long lived because everything lives at least as long as the I/O request is outstanding.