Method: Corosync::Quorum#dispatch

Defined in:
lib/corosync/quorum.rb

#dispatch(timeout = -1)) ⇒ Boolean

Checks for a single pending event and triggers the appropriate callback if found.

Parameters:

  • timeout (Integer) (defaults to: -1))

    How long to wait for an event.

    • -1: Indefinite. Wait forever

    • 0: Non-blocking. If there isn’t a pending event, return immediately

    • >0: Wait the specified number of seconds.

Returns:

  • (Boolean)

    Returns True if an event was triggered. Otherwise False.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/corosync/quorum.rb', line 97

def dispatch(timeout = -1)
  if !timeout != 0 then
    timeout = nil if timeout == -1
    select([@fd], [], [], timeout)
  end

  begin
    Corosync.cs_send!(:quorum_dispatch, @handle, Corosync::CS_DISPATCH_ONE_NONBLOCKING)
  rescue Corosync::TryAgainError => e
    raise e if e.depth > 1 # this exception is from a nested corosync function, not our quorum_dispatch we just called
    return false
  end

  return true
end