Roman Shaposhnick wrote:

 Suppose we're deep down in a call stack which looks somewhat like this:
main ...
        foo
           ...
              bar()

 now, there's a fixable exception that occurs in bar(), lets say a call
 to malloc that return NULL. Also suppose that I do have a strategy
 for dealing with OOM conditions, but I don't want it to clutter my
 bar() code. In fact, I don't even want it to be local to the process
 but rather implemented as a policy on a standalone server. All of that
 means that I can't just simply write:
try {
            malloc();
         } catch(...) {
            <fix it>
         }
but I have to transfer the control to the higher authority. I expect
 the codition which lead to OOM be fixed at that level, and all I want
 to have at the level of bar() is to see my malloc() call be restared.
 Automatically. Alternatively the authority could decide that malloc()
 has to be terminated at which point my control flow will resume past
the 'malloc();'.
 Now, we have a mechanism for the exception to be propagated upwards
 (I can even do it in C with things like waserror()), but there's no
 mechanism for the "fix" to be "propagated" downwards and have
my call to malloc be automatically restarted.
 On one hand it shouldn't be too hard to make such a thing part of the
 language, but I haven't seen anything like it yet. So are there any
 better solutions to the problem I've just described or am I talking
 nonsense here ? ;)
What about creating a Plan9-thread for the error recovery mecanism. This thread
would wait for the message on the channel. When we encounter malloc error we
send message on the error chanel. Error recovery process error and send message
back to us. Getting message we restart malloc...
All this require carefull coding, so I didn't try to write an example by myself, but
I think it's possible.
--
Victor

Reply via email to