Class: FDB::LazyFuture

Inherits:
Future
  • Object
show all
Defined in:
lib/fdbimpl.rb

Direct Known Subclasses

FutureStringArray, Int64Future, LazyString

Instance Method Summary collapse

Methods inherited from Future

#block_until_ready, #callback_wrapper, #cancel, finalize, #on_ready, #ready?, wait_for_any

Constructor Details

#initialize(fpointer) ⇒ LazyFuture

Returns a new instance of LazyFuture.



423
424
425
426
427
# File 'lib/fdbimpl.rb', line 423

def initialize(fpointer)
  super(fpointer)
  @set = false
  @value = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



419
420
421
# File 'lib/fdbimpl.rb', line 419

def method_missing( *args, &block )
  value.__send__( *args, &block )
end

Instance Method Details

#respond_to?(message) ⇒ Boolean

Returns:

  • (Boolean)


412
413
414
415
416
417
# File 'lib/fdbimpl.rb', line 412

def respond_to?(message)
  message = message.to_sym
  message == :__result__ or
    message == :to_ptr or
    value.respond_to? message
end

#valueObject



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/fdbimpl.rb', line 429

def value
  if !@set
    block_until_ready

    begin
      getter
      release_memory
    rescue Error => e
      if e.code != 1102 # future_released
        raise
      end
    end

    @set = true
  end

  @value
end