summary refs log tree commit diff stats
path: root/lib/core/locks.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-11-18 01:36:20 +0100
committerAraq <rumpf_a@web.de>2012-11-18 01:36:20 +0100
commit3c0a6a89629884b652bf351cb0cee5c94548effc (patch)
treef9053489e93a46e47701a8218d7cc9bd4b92b97f /lib/core/locks.nim
parent7f6633a06feeac8d6bd1eb1e6d8e841591326618 (diff)
downloadNim-3c0a6a89629884b652bf351cb0cee5c94548effc.tar.gz
'assert' hides EAssertionFailsure; stdlib makes use of 'tags'
Diffstat (limited to 'lib/core/locks.nim')
-rw-r--r--lib/core/locks.nim13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/core/locks.nim b/lib/core/locks.nim
index 083cc18d7..071bde93a 100644
--- a/lib/core/locks.nim
+++ b/lib/core/locks.nim
@@ -23,6 +23,13 @@ type
                     ## in preventDeadlocks-mode guarantees re-entrancy.
   TCond* = TSysCond ## Nimrod condition variable
   
+  FLock* = object of TEffect ## effect that denotes that some lock operation
+                             ## is performed
+  FAquireLock* = object of FLock  ## effect that denotes that some lock is
+                                  ## aquired
+  FReleaseLock* = object of FLock ## effect that denotes that some lock is
+                                  ## released
+  
 const
   noDeadlocks = defined(preventDeadlocks)
   maxLocksPerThread* = 10 ## max number of locks a thread can hold
@@ -51,7 +58,7 @@ proc DeinitLock*(lock: var TLock) {.inline.} =
   ## Frees the resources associated with the lock.
   DeinitSys(lock)
 
-proc TryAcquire*(lock: var TLock): bool = 
+proc TryAcquire*(lock: var TLock): bool {.tags: [FAquireLock].} = 
   ## Tries to acquire the given lock. Returns `true` on success.
   result = TryAcquireSys(lock)
   when noDeadlocks:
@@ -83,7 +90,7 @@ proc TryAcquire*(lock: var TLock): bool =
     inc(locksLen)
     assert OrderedLocks()
 
-proc Acquire*(lock: var TLock) =
+proc Acquire*(lock: var TLock) {.tags: [FAquireLock].} =
   ## Acquires the given lock.
   when nodeadlocks:
     var p = addr(lock)
@@ -128,7 +135,7 @@ proc Acquire*(lock: var TLock) =
   else:
     AcquireSys(lock)
   
-proc Release*(lock: var TLock) =
+proc Release*(lock: var TLock) {.tags: [FReleaseLock].} =
   ## Releases the given lock.
   when nodeadlocks:
     var p = addr(lock)