class Caliper::Stats::AtomicWrapper

Public Class Methods

new(value) click to toggle source
Calls superclass method
# File lib/caliper/stats/atomic_wrapper.rb, line 27
def initialize(value)
        super.initialize(value)
end

Public Instance Methods

add_and_get(delta) click to toggle source

Atomically adds the given value to the current value. Return the updated value

# File lib/caliper/stats/atomic_wrapper.rb, line 89
def add_and_get(delta)
        current = @value
        new_value = current + delta
        if (compare_and_set(current, new_value))
                new_value
        end
end
decrement_and_get() click to toggle source

Atomically decrements by one the current value. Return the updated value

# File lib/caliper/stats/atomic_wrapper.rb, line 79
def decrement_and_get()
        current = @value
        new_value = current - 1
        if (compare_and_set(current, new_value))
                new_value
        end
end
get_and_add(delta) click to toggle source

Atomically adds the given value to the current value Return the old value

# File lib/caliper/stats/atomic_wrapper.rb, line 59
def get_and_add(delta)
        current = @value
        new_value = current + delta
        if (compare_and_set(current, new_value))
                current
        end
end
get_and_decrement() click to toggle source

Atomically decrements by one and returns the old value.

# File lib/caliper/stats/atomic_wrapper.rb, line 49
def get_and_decrement()
        current = @value
        new_value = current - 1
        if (compare_and_set(current, new_value))
                current
        end
end
get_and_increment() click to toggle source

Atomically increments by one and returns the old value.

# File lib/caliper/stats/atomic_wrapper.rb, line 40
def get_and_increment()
        current = @value
        new_value = current + 1
        if (compare_and_set(current, new_value))
                current
        end
end
get_and_set(new_value) click to toggle source

Atomically sets to the given value and returns the old value.

# File lib/caliper/stats/atomic_wrapper.rb, line 32
def get_and_set(new_value)
        current = @value
        if (compare_and_set(current, new_value))
                current
        end
end
increment_and_get() click to toggle source

Atomically increments by one the current value. Return the updated value

# File lib/caliper/stats/atomic_wrapper.rb, line 69
def increment_and_get()
        current = @value
        new_value = current + 1
        if (compare_and_set(current, new_value))
                new_value
        end
end
to_string() click to toggle source

Returns the String representation of the current value.

# File lib/caliper/stats/atomic_wrapper.rb, line 98
def to_string()
        return @value.to_s
end