Class: Bio::MAF::CompletionTracker
- Inherits:
-
Object
- Object
- Bio::MAF::CompletionTracker
- Defined in:
- lib/bio/maf/parser.rb
Instance Attribute Summary collapse
- #delayed ⇒ Object readonly
- #offsets ⇒ Object readonly
- #queue ⇒ Object readonly
Instance Method Summary collapse
- #<<(blocks) ⇒ Object
- #drain_delayed ⇒ Object
-
#initialize(fetch_list) ⇒ CompletionTracker
constructor
A new instance of CompletionTracker.
- #next_expected ⇒ Object
Constructor Details
#initialize(fetch_list) ⇒ CompletionTracker
Returns a new instance of CompletionTracker.
1018 1019 1020 1021 1022 1023 |
# File 'lib/bio/maf/parser.rb', line 1018 def initialize(fetch_list) @offsets = fetch_list.collect { |e| e[0] } @queue = java.util.concurrent.LinkedBlockingQueue.new(128) @delayed = {} @sem = Mutex.new end |
Instance Attribute Details
#delayed ⇒ Object (readonly)
1016 1017 1018 |
# File 'lib/bio/maf/parser.rb', line 1016 def delayed @delayed end |
#offsets ⇒ Object (readonly)
1016 1017 1018 |
# File 'lib/bio/maf/parser.rb', line 1016 def offsets @offsets end |
#queue ⇒ Object (readonly)
1016 1017 1018 |
# File 'lib/bio/maf/parser.rb', line 1016 def queue @queue end |
Instance Method Details
#<<(blocks) ⇒ Object
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/bio/maf/parser.rb', line 1029 def <<(blocks) @sem.synchronize do f_offset = blocks.first.offset if f_offset == next_expected offsets.shift queue.put(blocks) drain_delayed else # out of order delayed[f_offset] = blocks end end end |
#drain_delayed ⇒ Object
1043 1044 1045 1046 1047 1048 |
# File 'lib/bio/maf/parser.rb', line 1043 def drain_delayed while e = delayed.delete(next_expected) offsets.shift queue.put(e) end end |
#next_expected ⇒ Object
1025 1026 1027 |
# File 'lib/bio/maf/parser.rb', line 1025 def next_expected offsets.first end |