Class | Rinda::TupleBag |
In: |
lib/rinda/tuplespace.rb
|
Parent: | Object |
TupleBag is an unordered collection of tuples. It is the basis of Tuplespace.
Delete tuples which dead tuples from the TupleBag, returning the deleted tuples.
# File lib/rinda/tuplespace.rb, line 382 382: def delete_unless_alive 383: deleted = [] 384: @hash.each do |key, bin| 385: bin.delete_if do |tuple| 386: if tuple.alive? 387: false 388: else 389: deleted.push(tuple) 390: true 391: end 392: end 393: end 394: deleted 395: end
Finds a live tuple that matches template.
# File lib/rinda/tuplespace.rb, line 362 362: def find(template) 363: bin_for_find(template).find do |tuple| 364: tuple.alive? && template.match(tuple) 365: end 366: end
Finds all live tuples that match template.
# File lib/rinda/tuplespace.rb, line 353 353: def find_all(template) 354: bin_for_find(template).find_all do |tuple| 355: tuple.alive? && template.match(tuple) 356: end 357: end
# File lib/rinda/tuplespace.rb, line 413 413: def bin_for_find(template) 414: key = bin_key(template) 415: key ? @hash.fetch(key, []) : @enum 416: end
# File lib/rinda/tuplespace.rb, line 404 404: def bin_key(tuple) 405: head = tuple[0] 406: if head.class == Symbol 407: return head 408: else 409: false 410: end 411: end