Sha256: 107e0bcb322b567d36428287a317390aa81084ae88560583d0c0e0b0e3c07337

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

require 'posix/mqueue'

class Localjob
  class LinuxAdapter
    attr_reader :mqueue

    def initialize(name)
      @mqueue = POSIX::Mqueue.new(fix_queue_name(name))
    end

    def receive
      @mqueue.timedreceive
    end

    def send(message)
      @mqueue.timedsend message
    end

    def size
      @mqueue.size
    end

    def destroy
      @mqueue.unlink
    end

    def to_io
      @mqueue.to_io
    end

    private
    def fix_queue_name(name)
      name.start_with?('/') ? name : "/#{name}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
localjob-0.1.0 lib/localjob/linux_adapter.rb