Sha256: d0fd91d5b2a81de6e58297b6cff9d930f017dfe1cba1683bda35ecc8707a4b6d

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
# Copyright 2014 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Aerospike

  private

  # Container object for client policy command.
  class Atomic # :nodoc:

    def initialize(value)
      @value = value

      @mutex = Mutex.new
    end

    def update(&block)
      @mutex.synchronize do
        @value = block.call(@value)
      end
    end

    def get
      ret = nil
      @mutex.synchronize do
        ret = @value
      end
      ret
    end
    alias_method :value, :get

    def set(value)
      @mutex.synchronize do
        @value = value
      end
    end
    alias_method 'value='.to_sym, :set

  end # class

end # module

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aerospike-2.1.1 lib/aerospike/atomic/atomic.rb
aerospike-2.1.0 lib/aerospike/atomic/atomic.rb
aerospike-2.0.0 lib/aerospike/atomic/atomic.rb
aerospike-1.0.12 lib/aerospike/atomic/atomic.rb
aerospike-1.0.11 lib/aerospike/atomic/atomic.rb
aerospike-1.0.10 lib/aerospike/atomic/atomic.rb
aerospike-1.0.9 lib/aerospike/atomic/atomic.rb
aerospike-1.0.8 lib/aerospike/atomic/atomic.rb
aerospike-1.0.7 lib/aerospike/atomic/atomic.rb
aerospike-1.0.6 lib/aerospike/atomic/atomic.rb
aerospike-1.0.5 lib/aerospike/atomic/atomic.rb
aerospike-1.0.4 lib/aerospike/atomic/atomic.rb
aerospike-1.0.3 lib/aerospike/atomic/atomic.rb
aerospike-1.0.2 lib/aerospike/atomic/atomic.rb
aerospike-1.0.1 lib/aerospike/atomic/atomic.rb
aerospike-1.0.0 lib/aerospike/atomic/atomic.rb