Class: Vertx::Counter
- Inherits:
-
Object
- Object
- Vertx::Counter
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb
Overview
An asynchronous counter that can be used to across the cluster to maintain a consistent count.
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) addAndGet(value, resultHandler) { ... }
Add the value to the counter atomically and return the new count.
-
- (void) compareAndSet(expected, value, resultHandler) { ... }
Set the counter to the specified value only if the current value is the expectec value.
-
- (void) decrementAndGet(resultHandler) { ... }
Decrement the counter atomically and return the new count.
-
- (void) get(resultHandler) { ... }
Get the current value of the counter.
-
- (void) getAndAdd(value, resultHandler) { ... }
Add the value to the counter atomically and return the value before the add.
-
- (void) getAndIncrement(resultHandler) { ... }
Increment the counter atomically and return the value before the increment.
-
- (void) incrementAndGet(resultHandler) { ... }
Increment the counter atomically and return the new count.
Class Method Details
+ (Boolean) accept?(obj)
20 21 22 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 20 def @@j_api_type.accept?(obj) obj.class == Counter end |
+ (Object) j_api_type
29 30 31 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.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/counter.rb', line 32 def self.j_class Java::IoVertxCoreShareddata::Counter.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/counter.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/counter.rb', line 23 def @@j_api_type.wrap(obj) Counter.new(obj) end |
Instance Method Details
- (void) addAndGet(value, resultHandler) { ... }
This method returns an undefined value.
Add the value to the counter atomically and return the new count
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 144 def add_and_get(*args) if args[0].class == Fixnum && true if (block_given?) return @j_del.java_method(:addAndGet, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:addAndGet, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling add_and_get(#{args[0]})" end end |
- (void) compareAndSet(expected, value, resultHandler) { ... }
This method returns an undefined value.
Set the counter to the specified value only if the current value is the expectec value. This happens atomically.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 82 def compare_and_set(*args) if args[0].class == Fixnum && args[1].class == Fixnum && true if (block_given?) return @j_del.java_method(:compareAndSet, [Java::long.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],args[1],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:compareAndSet, [Java::long.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],args[1],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling compare_and_set(#{args[0]},#{args[1]})" end end |
- (void) decrementAndGet(resultHandler) { ... }
This method returns an undefined value.
Decrement the counter atomically and return the new count
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 164 def decrement_and_get if true if (block_given?) return @j_del.java_method(:decrementAndGet, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:decrementAndGet, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling decrement_and_get()" end end |
- (void) get(resultHandler) { ... }
This method returns an undefined value.
Get the current value of the counter
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 102 def get if true if (block_given?) return @j_del.java_method(:get, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:get, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling get()" end end |
- (void) getAndAdd(value, resultHandler) { ... }
This method returns an undefined value.
Add the value to the counter atomically and return the value before the add
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 123 def get_and_add(*args) if args[0].class == Fixnum && true if (block_given?) return @j_del.java_method(:getAndAdd, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:getAndAdd, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling get_and_add(#{args[0]})" end end |
- (void) getAndIncrement(resultHandler) { ... }
This method returns an undefined value.
Increment the counter atomically and return the value before the increment.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 39 def get_and_increment if true if (block_given?) return @j_del.java_method(:getAndIncrement, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:getAndIncrement, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling get_and_increment()" end end |
- (void) incrementAndGet(resultHandler) { ... }
This method returns an undefined value.
Increment the counter atomically and return the new count
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 59 def increment_and_get if true if (block_given?) return @j_del.java_method(:incrementAndGet, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:incrementAndGet, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling increment_and_get()" end end |