Class: ThreadSafe::AtomicReferenceCacheBackend::Table

### Home Classes Methods

### In Files

- lib/thread_safe/atomic_reference_cache_backend.rb

### Parent

Util::PowerOfTwoTuple

### Methods

- #cas_new_node
- #delete_node_at
- #try_lock_via_hash
- #try_to_cas_in_computed

### Class/Module Index

Quicksearch

- ThreadSafe
- ThreadSafe::Array
- ThreadSafe::AtomicReferenceCacheBackend
- ThreadSafe::AtomicReferenceCacheBackend::Node
- ThreadSafe::AtomicReferenceCacheBackend::Table
- ThreadSafe::Cache
- ThreadSafe::Hash
- ThreadSafe::MriCacheBackend
- ThreadSafe::NonConcurrentCacheBackend
- ThreadSafe::SynchronizedCacheBackend
- ThreadSafe::Util
- ThreadSafe::Util::Adder
- ThreadSafe::Util::CheapLockable
- ThreadSafe::Util::PowerOfTwoTuple
- ThreadSafe::Util::Striped64
- ThreadSafe::Util::Striped64::Cell
- ThreadSafe::Util::Volatile
- ThreadSafe::Util::VolatileTuple
- SynchronizedDelegator
- Threadsafe

No matching classes.

# ThreadSafe::AtomicReferenceCacheBackend::Table

### Public Instance Methods

cas_new_node(i, hash, key, value) click to toggle source

    # File lib/thread_safe/atomic_reference_cache_backend.rb, line 182
    def cas_new_node(i, hash, key, value)
      cas(i, nil, Node.new(hash, key, value))
    end

delete_node_at(i, node, predecessor_node) click to toggle source

    # File lib/thread_safe/atomic_reference_cache_backend.rb, line 212
    def delete_node_at(i, node, predecessor_node)
      if predecessor_node
        predecessor_node.next = node.next
      else
        volatile_set(i, node.next)
      end
    end

try_lock_via_hash(i, node, node_hash) click to toggle source

    # File lib/thread_safe/atomic_reference_cache_backend.rb, line 206
    def try_lock_via_hash(i, node, node_hash)
      node.try_lock_via_hash(node_hash) do
        yield if volatile_get(i) == node
      end
    end

try_to_cas_in_computed(i, hash, key) click to toggle source

    # File lib/thread_safe/atomic_reference_cache_backend.rb, line 186
    def try_to_cas_in_computed(i, hash, key)
      succeeded = false
      new_value = nil
      new_node  = Node.new(locked_hash = hash | LOCKED, key, NULL)
      if cas(i, nil, new_node)
        begin
          if NULL == (new_value = yield(NULL))
            was_null = true
          else
            new_node.value = new_value
          end
          succeeded = true
        ensure
          volatile_set(i, nil) if !succeeded || was_null
          new_node.unlock_via_hash(locked_hash, hash)
        end
      end
      return succeeded, new_value
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.