Been a long time! I found this post by Ohad extremely useful. This is about implementing functions that will time out after a specified time interval. This behavior would be expected in various cases - for example - when you wait for a web service to respond to you. So in this case you may choose to time out after you wait for 's' seconds and try some other service, for instance.
This is the link -