Is there a means of limiting how long a method is permiited to run? I
want to be able to mark a method with a number and have the method
throw, say, a TooMuchTimeException if the running time exceeds this
I am envisioning declaratively applying such limits, either in the
class definition or setting the limits on individual objects.
Example: class Foo has instance methods calc1, cal2, etc. Depending
on the state of the foo object and the parameters passed into the
methods, these methods might run in a fraction of the second or they
might take minutes.
#complex work …
def calc2(a, b)
#more complex work …
#declare maximum time limit like this…
#TooMuchTimeException exception to be thrown if method takes too long
time_limit :calc1=>5, :calc2=>20
Is there anything already written that does this type of thing?