You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 31, 2025. It is now read-only.
Phillip Allen Lane edited this page Nov 27, 2023
·
1 revision
DotMP provides a locking API. For performance, it's advised to use the .NET lock keyword. However, this API is provided for those who want a locking API more similar to that which is used in OpenMP.
To create a lock, you can instantiate a DotMP.Lock object:
DotMP.Locklck=newDotMP.Lock();
There are several methods you can call on a lock:
Obtaining a Lock
If you call:
lck.Set();
The current thread is halted until the lock is obtained, at which point execution proceeds as normal.
Freeing a Lock
If you call:
lck.Unset();
The current lock is freed for other threads to use.
Testing a Lock
If you call:
boolsuccess=lck.Test();
This attempts to obtain a lock without blocking the thread. If the thread was successful in obtaining the lock, Test() returns true. If the lock has already been obtained by another thread, Test() returns false. Again, in neither case is the current thread blocked.