Class: Royal::Locking::Advisory

Inherits:
Object
  • Object
show all
Defined in:
lib/royal/locking/advisory.rb

Constant Summary collapse

ID_LOBITS_MASK =

Used to extract the lower 32-bits of owner IDs. The 2-argument version of ‘pg_advisory_xact_lock` accepts 32 bit integers, and this ensures we do not overflow that constraint.

0xFFFFFFFF

Instance Method Summary collapse

Instance Method Details

#call(owner) ⇒ Object

Parameters:

  • owner (ActiveRecord::Base)


12
13
14
15
16
17
# File 'lib/royal/locking/advisory.rb', line 12

def call(owner)
  PointBalance.transaction(requires_new: true) do
    acquire_advisory_lock_on_owner(owner)
    yield
  end
end