Class List Method List File List

# Class: VertxUnit::Async

Inherits:
  Completion
  - Object
  - Completion
  - VertxUnit::Async
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb

## Overview

An asynchronous exit point for a test.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) await(timeoutMillis = nil)
  Cause the current thread to wait until this completion completes with a configurable timeout.
- - (void) await_success(timeoutMillis = nil)
  Cause the current thread to wait until this completion completes and succeeds with a configurable timeout.
- - (void) complete
  Signals the asynchronous operation is done, this method must be called with a count greater than 0, otherwise it throws an IllegalStateException to signal the error.
- - (true, false) completed?
  True if this completion is completed.
- - (Fixnum) count
  The current count.
- - (void) count_down
  Count down the async.
- - (true, false) failed?
  True if the this completion is completed and failed.
- - (void) handler { ... }
  Completion handler to receive a completion signal when this completions completes.
- - (void) resolve(future = nil)
  Completes the future upon completion, otherwise fails it.
- - (true, false) succeeded?
  True if this completion is completed and succeeded.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    20
    21
    22
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 20

    def @@j_api_type.accept?(obj)
      obj.class == Async
    end

### + (`Object`) j_api_type

    29
    30
    31
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 29

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 32

    def self.j_class
      Java::IoVertxExtUnit::Async.java_class
    end

### + (`Object`) unwrap(obj)

    26
    27
    28
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 26

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    23
    24
    25
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 23

    def @@j_api_type.wrap(obj)
      Async.new(obj)
    end

## Instance Method Details

### - (`void`) await(timeoutMillis = nil)

This method returns an undefined value.

Cause the current thread to wait until this completion completes with a configurable timeout.

If completion times out or the current thread is interrupted, an exception will be thrown.

Parameters:

- timeoutMillis (`Fixnum`) (defaults to: `nil`) —
  the timeout in milliseconds

Raises:

- (`ArgumentError`)

    79
    80
    81
    82
    83
    84
    85
    86
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 79

    def await(timeoutMillis=nil)
      if !block_given? && timeoutMillis == nil
        return @j_del.java_method(:await, []).call()
      elsif timeoutMillis.class == Fixnum && !block_given?
        return @j_del.java_method(:await, [Java::long.java_class]).call(timeoutMillis)
      end
      raise ArgumentError, "Invalid arguments when calling await(#{timeoutMillis})"
    end

### - (`void`) await_success(timeoutMillis = nil)

This method returns an undefined value.

Cause the current thread to wait until this completion completes and succeeds with a configurable timeout.

If completion times out or the current thread is interrupted or the suite fails, an exception will be thrown.

Parameters:

- timeoutMillis (`Fixnum`) (defaults to: `nil`) —
  the timeout in milliseconds

Raises:

- (`ArgumentError`)

    92
    93
    94
    95
    96
    97
    98
    99
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 92

    def await_success(timeoutMillis=nil)
      if !block_given? && timeoutMillis == nil
        return @j_del.java_method(:awaitSuccess, []).call()
      elsif timeoutMillis.class == Fixnum && !block_given?
        return @j_del.java_method(:awaitSuccess, [Java::long.java_class]).call(timeoutMillis)
      end
      raise ArgumentError, "Invalid arguments when calling await_success(#{timeoutMillis})"
    end

### - (`void`) complete

This method returns an undefined value.

Signals the asynchronous operation is done, this method must be called with a count greater than `0`, otherwise it throws an `IllegalStateException` to signal the error.

Raises:

- (`ArgumentError`)

    118
    119
    120
    121
    122
    123
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 118

    def complete
      if !block_given?
        return @j_del.java_method(:complete, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling complete()"
    end

### - (`true`, `false`) completed?

Returns true if this completion is completed

Returns:

- (`true`, `false`) —
  true if this completion is completed

Raises:

- (`ArgumentError`)

    45
    46
    47
    48
    49
    50
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 45

    def completed?
      if !block_given?
        return @j_del.java_method(:isCompleted, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling completed?()"
    end

### - (`Fixnum`) count

Returns the current count

Returns:

- (`Fixnum`) —
  the current count

Raises:

- (`ArgumentError`)

    101
    102
    103
    104
    105
    106
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 101

    def count
      if !block_given?
        return @j_del.java_method(:count, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling count()"
    end

### - (`void`) count_down

This method returns an undefined value.

Count down the async.

Raises:

- (`ArgumentError`)

    109
    110
    111
    112
    113
    114
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 109

    def count_down
      if !block_given?
        return @j_del.java_method(:countDown, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling count_down()"
    end

### - (`true`, `false`) failed?

Returns true if the this completion is completed and failed

Returns:

- (`true`, `false`) —
  true if the this completion is completed and failed

Raises:

- (`ArgumentError`)

    59
    60
    61
    62
    63
    64
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 59

    def failed?
      if !block_given?
        return @j_del.java_method(:isFailed, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling failed?()"
    end

### - (`void`) handler { ... }

This method returns an undefined value.

Completion handler to receive a completion signal when this completions completes.

Yields:

- the completion handler

Raises:

- (`ArgumentError`)

    68
    69
    70
    71
    72
    73
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 68

    def handler
      if block_given?
        return @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling handler()"
    end

### - (`void`) resolve(future = nil)

This method returns an undefined value.

Completes the future upon completion, otherwise fails it.

Parameters:

- future (`::Vertx::Promise`) (defaults to: `nil`) —
  the future to resolve

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 38

    def resolve(future=nil)
      if future.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:resolve, [Java::IoVertxCore::Promise.java_class]).call(future.j_del)
      end
      raise ArgumentError, "Invalid arguments when calling resolve(#{future})"
    end

### - (`true`, `false`) succeeded?

Returns true if this completion is completed and succeeded

Returns:

- (`true`, `false`) —
  true if this completion is completed and succeeded

Raises:

- (`ArgumentError`)

    52
    53
    54
    55
    56
    57
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-unit/async.rb', line 52

    def succeeded?
      if !block_given?
        return @j_del.java_method(:isSucceeded, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling succeeded?()"
    end