Sha256: 8a22fd9ce9dd052c1e200426ff0ae465f6c24a076a6d31e4622d2a7faac4982a
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
class PartialContinuation attr_accessor :markerBlock, :partial def self.currentDomarkerBlock(block, markerBlock) if (marker = markerBlock.call).nil? raise RuntimeError, 'Marker not found when capturing partial continuation.' end return block.call to_offset_markerBlock(marker, 1, markerBlock) end def self.to_offset_markerBlock(method, offset, &block) idx = find_frame_for(method) partial = Thread.__partialContinuationFromLevel_to(3 + offset, idx) new.tap do |o| o.partial = partial o.markerBlock = block end end def self.find_frame_for(method) index = 1 while frame = Thread.current.__frame_contents_at(index) do if frame[0] == method return level else level += 1 end end nil end def call(arg = nil) marker = markerBlock.call if marker.nil? marker = Thread.current.__frame_contents_at(2).first frameIndex = 2 else frameIndex = self.class.find_frame_for marker end Thread.current.__installPartialContinuation_atLevel_value partial, frameIndex, arg end alias [] call end def test_callcc PartialContinuation.currentDomarkerBlock currentDo: aBlock markerBlock: [ self callbackMarker ] end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubymirrors-0.0.3 | lib/maglev/reflection/support/partial_continuation.rb |
rubymirrors-0.0.2 | lib/maglev/reflection/support/partial_continuation.rb |