@@ -690,7 +690,7 @@ A Perl 6 implementation of CAS would look something like this:
690
690
return $seen;
691
691
}
692
692
693
- Except that it happens atomically. For example, a crappy non-reenterant
693
+ Except that it happens atomically. For example, a crappy non-reentrant
694
694
mutex could be implemented as:
695
695
696
696
class CrappyMutex {
@@ -711,9 +711,9 @@ Another common use of CAS is in providing lock-free data structures. Any data
711
711
structure can be made lock-free as long as you're willing to never mutate it,
712
712
but build a fresh one each time. To support this, there is another C<&cas>
713
713
candidate that takes a scalar and a block. It calls the block with the seen
714
- initial value. The block should return a the new, updated value. If nothing
715
- else updated the value in the meantime, the reference will be updated. In the
716
- case the CAS fails because another update got in first, the block will be run
714
+ initial value. The block returns the new, updated value. If nothing
715
+ else updated the value in the meantime, the reference will be updated. If
716
+ the CAS fails because another update got in first, the block will be run
717
717
again, passing in the latest value.
718
718
719
719
For example, we could implement a top-5 news headlines list, which can be
@@ -742,8 +742,8 @@ of times).
742
742
=head1 Locks
743
743
744
744
Locks are unpleasant to work with, and users are pushed towards higher level
745
- synchronization primitives. However, those need to be implemented in lower
746
- level things for efficiency. As such, a simple lock mechanism - as close to
745
+ synchronization primitives. However, those need to be implemented via lower
746
+ level constructs for efficiency. As such, a simple lock mechanism - as close to
747
747
what the execution environment offers as possible - is provided by the C<Lock>
748
748
class. Note that it is erroneous to rely on the exact representation of an
749
749
instance of this type (for example, don't assume it can be mixed into). Put
@@ -770,6 +770,6 @@ possible to do:
770
770
}
771
771
772
772
When using the C<lock> and C<unlock> methods, the programmer must ensure that
773
- the lock is unlocked. C<Lock> is reentrant. Naturally, it's possible to easily
773
+ the lock is unlocked. C<Lock> is reentrant. Naturally, it's easy to
774
774
introduce deadlocks. Again, this is a last resort, intended for those who are
775
775
building first resorts.
0 commit comments