Module RemoteSignaller
In: util/remotesignaller.rb

RemoteSignaller mixin

Advantages:

Disadvantages:

Example use:

Methods
add_signalled    count_signalled    del_all_signalled    del_signalled    signal_waiting   
Public Instance methods
add_signalled(sig, pid)

Add a process to be signalled.

sig
signal to be sent
pid
pid of process to be signalled
# File util/remotesignaller.rb, line 61
def add_signalled(sig, pid)
  @observers = Hash.new unless defined? @observers
  @observers[pid] = sig
end
signal_waiting(signum = "ALL")

Send signal to all waiting processes.

signum
Signal processes waiting on this signal, or all waiting processes if signum is "ALL". signum is a string naming the signal desired, or the string "ALL".
Returns:
Array of processes which could not be signalled.
# File util/remotesignaller.rb, line 74
def signal_waiting(signum = "ALL")
  dead = []
  if defined? @observers
    @observers.each_pair {
      |pid, sig|
      if signum == "ALL" || signum == sig
	begin
	  Process.kill(sig, pid)
	rescue
	  dead << pid
	end
      end
    }
  end
  dead
end
del_signalled(pid)

Delete a waiting process.

pid
Delete process with pid == pid.
# File util/remotesignaller.rb, line 94
def del_signalled(pid)
  @observers.delete(pid) if defined? @observers
end
del_all_signalled(signum = "ALL")

Delete all waiting processes.

signum
Delete processes waiting on this signal, or all waiting processes if signum is "ALL". signum is a string naming the signal desired, or the string "ALL".
# File util/remotesignaller.rb, line 104
def del_all_signalled(signum = "ALL")
  if defined? @observers
    @observers.delete_if { 
      |pid, sig|
      signum == "ALL" || signum == sig
    }
  end
end
count_signalled(signum = "ALL")

Count processes waiting on signals.

signum
Count processes waiting on this signal, or all waiting processes if signum is "ALL". signum is a string naming the signal desired, or the string "ALL".
# File util/remotesignaller.rb, line 119
def count_signalled(signum = "ALL")
  if defined? @observers
    @observers.find_all { 
      |pid, sig|
      signum == "ALL" || signum == sig
    }.size
  else
    0
  end
end