laforge49 / PAMailbox

0 stars 0 forks source link

Optional message processing timer #5

Open skunkiferous opened 11 years ago

skunkiferous commented 11 years ago

An optional timer on non-blocking mailboxes to ensure that all messages are processed in less than 1 millisecond.

skunkiferous commented 11 years ago

The timer is there to return a "timeout exception" as response if the requests takes too long. It has no effect on the processing of the request itself. This does not in effect actually deal with issues like infinite loop, as the loop just keeps on going, even if the caller gets a response.

laforge49 commented 11 years ago

The idea then is to limit the amount of time the requests of a non-blocking mailbox can run, not to limit the amount of time it takes to complete a request. Remember that requests are non-atomic, but message processing is atomic.

Indeed, this does not prevent loops which include a request/response, but it does address the commonest bug that I have experienced, which is forgetting to call ResponseProcessor.processResponse--which currently results in a mysterious hung program. Adding this check will make it much easier to locate this kind of bug and consequently it will be much easier to learn how to use PActor.

This will cause things to slow down a bit, so we need to either be able to disable it or implement it in a debug version of PAMailbox, or both.

laforge49 commented 11 years ago

When a timeout does occur, all we need to do (methinks!) is to create a timeout exception and return it as the result for the mailbox's current message.