Skip to content

Commit eb825ce

Browse files
committed
Mention Lock::Async in language/concurrency
1 parent c5a4cb2 commit eb825ce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/Language/concurrency.rakudoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,20 @@ C<protect> returns whatever the code block returns.
828828
Because C<protect> will block any threads that are waiting to execute
829829
the critical section the code should be as quick as possible.
830830

831+
=head2 Lock::Async
832+
833+
L<C<Lock::Async>|/type/Lock::Async> is a mutual exclusion mechanism much like
834+
Lock, but it exposes its functionality through C<Promise>s, allowing the use of
835+
C<await> when waiting for a lock to become available, instead of blocking an
836+
entire thread.
837+
838+
Another difference is that it is not re-entrant, meaning that the lock is not
839+
considered available to code that is C<protect>ed by the lock.
840+
841+
C<Lock::Async> is more high-level than C<Lock>, but it is still considered a
842+
low-level primitive. Higher-level primitives should be preferred over mutating
843+
shared data inside critical sections.
844+
831845
=head1 Safety concerns
832846

833847
Some shared data concurrency issues are less obvious than others.

0 commit comments

Comments
 (0)