Class: FDB::LazyFuture

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

Direct Known Subclasses

FutureStringArray, LazyString, Version

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.



416
417
418
419
420
# File 'lib/fdbimpl.rb', line 416

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



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

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

Instance Method Details

#respond_to?(message) ⇒ Boolean

Returns:

  • (Boolean)


405
406
407
408
409
410
# File 'lib/fdbimpl.rb', line 405

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

#valueObject



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/fdbimpl.rb', line 422

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