Module: Tra::Mailbox

Defined in:
lib/tra/mailbox.rb

Class Method Summary collapse

Class Method Details

.receiveObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/tra/mailbox.rb', line 4

def receive
  Dir.mkdir DIRECTORY unless Dir.exist? DIRECTORY
  file = FILE[Process.pid]

  Thread.new do
    Socket.unix_server_loop file do |socket|
      QUEUE << (Marshal.load socket.read size_of_message_from socket)
    end
  end

  sleep 0.01 until File.exist? file
end