Class: Rinda::TupleSpace Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pione/patch/rinda-patch.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TupleSpace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TupleSpace.



517
518
519
520
521
522
523
524
525
526
527
# File 'lib/pione/patch/rinda-patch.rb', line 517

def initialize(*args)
  orig_initialize(*args)
  @bag.set_special_bin(
    :task => TupleBag::DomainTupleBin,
    :finished => TupleBag::DomainTupleBin,
    :working => TupleBag::DomainTupleBin,
    :data => TupleBag::DataTupleBin,
    :lift => TupleBag::HashTupleBin
  )
  @mutex = Mutex.new
end

Instance Attribute Details

#bagObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



511
512
513
# File 'lib/pione/patch/rinda-patch.rb', line 511

def bag
  @bag
end

#read_waiterObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



513
514
515
# File 'lib/pione/patch/rinda-patch.rb', line 513

def read_waiter
  @read_waiter
end

#take_waiterObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



512
513
514
# File 'lib/pione/patch/rinda-patch.rb', line 512

def take_waiter
  @take_waiter
end

Instance Method Details

#all_tuples(target = :bag) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all tuples in the space.

Parameters:

  • target (Symbol) (defaults to: :bag)

    tuple type(:all, :bag, :read_waiter, or :take_waiter)

Returns:



558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/pione/patch/rinda-patch.rb', line 558

def all_tuples(target=:bag)
  case target
  when :all
    all_tuples(:bag) + all_tuples(:read_waiter) + all_tuples(:take_waiter)
  when :bag
    @mutex.synchronize{@bag.all_tuples}.map{|tuple| tuple.value}
  when :read_waiter
    @mutex.synchronize{@read_waiter.all_tuples}.map{|tuple| tuple.value}
  when :take_waiter
    @mutex.synchronize{@take_waiter.all_tuples}.map{|tuple| tuple.value}
  end
end

#data_sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



591
592
593
# File 'lib/pione/patch/rinda-patch.rb', line 591

def data_size
  @bag.data_size
end

#finished_sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



587
588
589
# File 'lib/pione/patch/rinda-patch.rb', line 587

def finished_size
  @bag.finished_size
end

#move(port, tuple, sec = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



534
535
536
# File 'lib/pione/patch/rinda-patch.rb', line 534

def move(port, tuple, sec=nil)
  real_move(port, tuple, sec)
end

#notify(event, tuple, sec = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

mutex version of +notify+



573
574
575
576
577
# File 'lib/pione/patch/rinda-patch.rb', line 573

def notify(event, tuple, sec=nil)
  template = NotifyTemplateEntry.new(self, event, tuple, sec)
  @mutex.synchronize {@notify_waiter.push(template)}
  template
end

#orig_initializeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



515
# File 'lib/pione/patch/rinda-patch.rb', line 515

alias :orig_initialize :initialize

#read(tuple, sec = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



538
539
540
# File 'lib/pione/patch/rinda-patch.rb', line 538

def read(tuple, sec=nil)
  lift_tuple(real_read(tuple, sec))
end

#read_all(tuple) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



542
543
544
545
546
# File 'lib/pione/patch/rinda-patch.rb', line 542

def read_all(tuple)
  real_read_all(tuple).map do |res|
    lift_tuple(res)
  end
end

#take_all(tuple, sec = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



548
549
550
# File 'lib/pione/patch/rinda-patch.rb', line 548

def take_all(tuple, sec=nil)
  real_take_all(tuple, sec).map {|res| lift_tuple(res)}
end

#task_sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



579
580
581
# File 'lib/pione/patch/rinda-patch.rb', line 579

def task_size
  @bag.task_size
end

#working_sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



583
584
585
# File 'lib/pione/patch/rinda-patch.rb', line 583

def working_size
  @bag.working_size
end

#write(tuple, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



529
530
531
532
# File 'lib/pione/patch/rinda-patch.rb', line 529

def write(tuple, *args)
  tuple.timestamp = Time.now
  real_write(tuple, *args)
end