Class RR::TaskSweeper
In: lib/rubyrep/task_sweeper.rb
Parent: Object

Monitors and cancels stalled tasks

Methods

join   new   ping   terminated?   timeout   timeout  

Attributes

last_ping  [RW]  Time of last ping
terminated  [RW]  Set to true if the executed task has timed out
thread  [RW]  The task executing thread
timeout_period  [RW]  Time in seconds after which a task is considered stalled. Timer is reset by calling ping.

Public Class methods

Creates a new TaskSweeper

  • timeout_period: timeout value in seconds

Executes the give block in a separate Thread. Returns if block is finished or stalled. The block must call regular ping to announce it is not stalled.

  • timeout_period: Maximum time (in seonds) without ping, after which a task is considered stalled.

Returns the created sweeper (allows checking if task was terminated).

Public Instance methods

Waits without timeout till the task executing thread is finished

Must be called by the executed task to announce it is still alive

Returns true if the task was timed out. The terminated task is expected to free all resources and exit.

Protected Instance methods

Executes the given block and times it out if stalled.

[Validate]