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) add_and_get(value = nil) { ... }
Add the value to the counter atomically and return the new count.
-
- (void) compare_and_set(expected = nil, value = nil) { ... }
Set the counter to the specified value only if the current value is the expectec value.
-
- (void) decrement_and_get { ... }
Decrement the counter atomically and return the new count.
-
- (void) get { ... }
Get the current value of the counter.
-
- (void) get_and_add(value = nil) { ... }
Add the value to the counter atomically and return the value before the add.
-
- (void) get_and_increment { ... }
Increment the counter atomically and return the value before the increment.
-
- (void) increment_and_get { ... }
Increment the counter atomically and return the new count.
Class Method Details
+ (Boolean) accept?(obj)
19 20 21 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 19 def @@j_api_type.accept?(obj) obj.class == Counter end |
+ (Object) j_api_type
28 29 30 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 28 def self.j_api_type @@j_api_type end |
+ (Object) j_class
31 32 33 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 31 def self.j_class Java::IoVertxCoreShareddata::Counter.java_class end |
+ (Object) unwrap(obj)
25 26 27 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 25 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
22 23 24 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 22 def @@j_api_type.wrap(obj) Counter.new(obj) end |
Instance Method Details
- (void) add_and_get(value = nil) { ... }
This method returns an undefined value.
Add the value to the counter atomically and return the new count
74 75 76 77 78 79 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 74 def add_and_get(value=nil) if value.class == Fixnum && true return @j_del.java_method(:addAndGet, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(value,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling add_and_get(#{value})" end |
- (void) compare_and_set(expected = nil, value = nil) { ... }
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.
96 97 98 99 100 101 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 96 def compare_and_set(expected=nil,value=nil) if expected.class == Fixnum && value.class == Fixnum && true return @j_del.java_method(:compareAndSet, [Java::long.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(expected,value,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling compare_and_set(#{expected},#{value})" end |
- (void) decrement_and_get { ... }
This method returns an undefined value.
Decrement the counter atomically and return the new count
64 65 66 67 68 69 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 64 def decrement_and_get if true return @j_del.java_method(:decrementAndGet, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling decrement_and_get()" end |
- (void) get { ... }
This method returns an undefined value.
Get the current value of the counter
37 38 39 40 41 42 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 37 def get if true return @j_del.java_method(:get, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling get()" end |
- (void) get_and_add(value = nil) { ... }
This method returns an undefined value.
Add the value to the counter atomically and return the value before the add
84 85 86 87 88 89 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 84 def get_and_add(value=nil) if value.class == Fixnum && true return @j_del.java_method(:getAndAdd, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(value,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling get_and_add(#{value})" end |
- (void) get_and_increment { ... }
This method returns an undefined value.
Increment the counter atomically and return the value before the increment.
55 56 57 58 59 60 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 55 def get_and_increment if true return @j_del.java_method(:getAndIncrement, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling get_and_increment()" end |
- (void) increment_and_get { ... }
This method returns an undefined value.
Increment the counter atomically and return the new count
46 47 48 49 50 51 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/counter.rb', line 46 def increment_and_get if true return @j_del.java_method(:incrementAndGet, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling increment_and_get()" end |