|
@@ -8,7 +8,7 @@ _ :: vg
|
|
|
Wait group.
|
|
|
|
|
|
Wait group is a synchronization primitive used by the waiting thread to wait,
|
|
|
-until a all working threads finish work.
|
|
|
+until all working threads finish work.
|
|
|
|
|
|
The waiting thread first sets the number of working threads it will expect to
|
|
|
wait for using `wait_group_add` call, and start waiting using `wait_group_wait`
|
|
@@ -35,7 +35,7 @@ Wait_Group :: struct #no_copy {
|
|
|
/*
|
|
|
Increment an internal counter of a wait group.
|
|
|
|
|
|
-This procedure atomicaly increments a number to the specified wait group's
|
|
|
+This procedure atomically increments a number to the specified wait group's
|
|
|
internal counter by a specified amount. This operation can be done on any
|
|
|
thread.
|
|
|
*/
|
|
@@ -121,7 +121,7 @@ When `barrier_wait` procedure is called by any thread, that thread will block
|
|
|
the execution, until all threads associated with the barrier reach the same
|
|
|
point of execution and also call `barrier_wait`.
|
|
|
|
|
|
-when barrier is initialized, a `thread_count` parameter is passed, signifying
|
|
|
+When a barrier is initialized, a `thread_count` parameter is passed, signifying
|
|
|
the amount of participant threads of the barrier. The barrier also keeps track
|
|
|
of an internal atomic counter. When a thread calls `barrier_wait`, the internal
|
|
|
counter is incremented. When the internal counter reaches `thread_count`, it is
|
|
@@ -208,7 +208,7 @@ Represents a thread synchronization primitive that, when signalled, releases one
|
|
|
single waiting thread and then resets automatically to a state where it can be
|
|
|
signalled again.
|
|
|
|
|
|
-When a thread calls `auto_reset_event_wait`, it's execution will be blocked,
|
|
|
+When a thread calls `auto_reset_event_wait`, its execution will be blocked,
|
|
|
until the event is signalled by another thread. The call to
|
|
|
`auto_reset_event_signal` wakes up exactly one thread waiting for the event.
|
|
|
*/
|
|
@@ -331,8 +331,8 @@ Benaphore.
|
|
|
|
|
|
A benaphore is a combination of an atomic variable and a semaphore that can
|
|
|
improve locking efficiency in a no-contention system. Acquiring a benaphore
|
|
|
-lock doesn't call into an internal semaphore, if no other thread in a middle of
|
|
|
-a critical section.
|
|
|
+lock doesn't call into an internal semaphore, if no other thread is in the
|
|
|
+middle of a critical section.
|
|
|
|
|
|
Once a lock on a benaphore is acquired by a thread, no other thread is allowed
|
|
|
into any critical sections, associted with the same benaphore, until the lock
|
|
@@ -381,7 +381,7 @@ Release a lock on a benaphore.
|
|
|
|
|
|
This procedure releases a lock on the specified benaphore. If any of the threads
|
|
|
are waiting on the lock, exactly one thread is allowed into a critical section
|
|
|
-associated with the same banaphore.
|
|
|
+associated with the same benaphore.
|
|
|
*/
|
|
|
benaphore_unlock :: proc "contextless" (b: ^Benaphore) {
|
|
|
if atomic_sub_explicit(&b.counter, 1, .Release) > 1 {
|
|
@@ -418,8 +418,8 @@ benaphore_guard :: proc "contextless" (m: ^Benaphore) -> bool {
|
|
|
/*
|
|
|
Recursive benaphore.
|
|
|
|
|
|
-Recurisve benaphore is just like a plain benaphore, except it allows reentrancy
|
|
|
-into the critical section.
|
|
|
+A recursive benaphore is just like a plain benaphore, except it allows
|
|
|
+reentrancy into the critical section.
|
|
|
|
|
|
When a lock is acquired on a benaphore, all other threads attempting to
|
|
|
acquire a lock on the same benaphore will be blocked from any critical sections,
|