Sha256: 6b2244fcbaec0124e046aa254a75eb80a1aaaca1ce7c2af69a1df09135acc162

Contents?: true

Size: 510 Bytes

Versions: 4

Compression:

Stored size: 510 Bytes

Contents

require 'sysvmq'

class Localjob
  class SysvAdapter
    RECEIVE_ALL_TYPES = 0

    attr_reader :queue

    def initialize(key, size: 8192, flags: SysVMQ::IPC_CREAT | 0660)
      @key = key
      @queue = SysVMQ.new(key, size, flags)
    end

    def receive
      queue.receive(RECEIVE_ALL_TYPES)
    end

    def send(message)
      queue.send(message, 1)
    end

    def size
      queue.stats[:count]
    end

    def stats
      queue.stats
    end

    def destroy
      queue.destroy
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
localjob-0.4.1 lib/localjob/sysv_adapter.rb
localjob-0.4.0 lib/localjob/sysv_adapter.rb
localjob-0.3.0 lib/localjob/sysv_adapter.rb
localjob-0.2.0 lib/localjob/sysv_adapter.rb