@@ -648,7 +648,8 @@ defmodule Registry do
648648 This function is useful only when spawning processes is not an option,
649649 for example, when copying the data to another process could be too
650650 expensive. Or when the work must be done within the current process
651- for other reasons.
651+ for other reasons. In such cases, this function provides a scalable
652+ mechanism for managing locks on top of the registry's infrastructure.
652653
653654 ## Examples
654655
@@ -663,8 +664,8 @@ defmodule Registry do
663664 def lock ( registry , lock_key , function )
664665 when is_atom ( registry ) and is_function ( function , 0 ) do
665666 { _kind , partitions , _ , pid_ets , _ } = info! ( registry )
666- { pid_server , _pid_ets } = pid_ets || pid_ets! ( registry , key , partitions )
667- Registry.Partition . lock ( pid_server , key , function )
667+ { pid_server , _pid_ets } = pid_ets || pid_ets! ( registry , lock_key , partitions )
668+ Registry.Partition . lock ( pid_server , lock_key , function )
668669 end
669670
670671 @ doc """
@@ -1593,7 +1594,7 @@ defmodule Registry.Partition do
15931594 Runs function with a lock.
15941595 """
15951596 def lock ( pid , key , lock ) do
1596- { :ok , ref } = GenServer . call ( pid , { :lock , key } )
1597+ ref = GenServer . call ( pid , { :lock , key } )
15971598
15981599 try do
15991600 lock . ( )
@@ -1732,6 +1733,6 @@ defmodule Registry.Partition do
17321733
17331734 defp go ( { pid , _tag } = from , key ) do
17341735 ref = Process . monitor ( pid , tag: { :unlock , key } )
1735- GenServer . reply ( from , { :ok , ref } )
1736+ GenServer . reply ( from , ref )
17361737 end
17371738end
0 commit comments