Class: TotenDev::Kiwi
- Inherits:
-
Object
- Object
- TotenDev::Kiwi
- Defined in:
- lib/tdev_kiwi.rb
Constant Summary collapse
- IPC_CREAT =
001000- IPC_EXCL =
002000- IPC_NOWAIT =
004000- IPC_R =
000400- IPC_W =
000200- IPC_M =
010000
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#queue_id ⇒ Object
Returns the value of attribute queue_id.
-
#queue_key ⇒ Object
readonly
Returns the value of attribute queue_key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(qk, qid = 'TDKiwi') ⇒ Kiwi
constructor
A new instance of Kiwi.
- #send(msg = @message) ⇒ Object
Constructor Details
#initialize(qk, qid = 'TDKiwi') ⇒ Kiwi
Returns a new instance of Kiwi.
37 38 39 40 41 |
# File 'lib/tdev_kiwi.rb', line 37 def initialize(qk, qid = 'TDKiwi') @queue_id = qid @queue_key = qk @kiwi = self.class.get(qk) unless qk.nil? end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
34 35 36 |
# File 'lib/tdev_kiwi.rb', line 34 def end |
#queue_id ⇒ Object
Returns the value of attribute queue_id.
34 35 36 |
# File 'lib/tdev_kiwi.rb', line 34 def queue_id @queue_id end |
#queue_key ⇒ Object (readonly)
Returns the value of attribute queue_key.
35 36 37 |
# File 'lib/tdev_kiwi.rb', line 35 def queue_key @queue_key end |
Class Method Details
.get(queue_key, msgflag = IPC_CREAT | IPC_R | IPC_W | IPC_M) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/tdev_kiwi.rb', line 43 def self.get( queue_key, msgflag = IPC_CREAT | IPC_R | IPC_W | IPC_M ) return nil if LIBC.nil? queue_key = queue_key.to_i if queue_key.is_a? String Fiddle::Function.new( LIBC['msgget'], [Fiddle::TYPE_INT, Fiddle::TYPE_INT], Fiddle::TYPE_INT ) .call( queue_key, msgflag ) end |
Instance Method Details
#send(msg = @message) ⇒ Object
52 53 54 55 |
# File 'lib/tdev_kiwi.rb', line 52 def send( msg = ) wrapper = "#{@queue_id}||#{msg.worker}||'#{msg.args}'" sender( "s:#{wrapper.length}:\"#{wrapper}\"" ) end |