We use non-recursive locks too. The pattern is:
---
bool wasMyLock=obj.isMyLock();
if(!wasMyLock)obj.lock();
...code...
if(!wasMyLock)obj.unlock();
---
On 03/05/2014 09:49 AM, Jeremy DeHaan wrote:
> On Monday, 3 March 2014 at 07:38:05 UTC, Ali Çehreli wrote:
>> The documentation says that Mutex is a recursive lock, meaning that
>> the holder of the lock can lock it even further. :) There is an
>> internal reference count so that the lock must be
On Monday, 3 March 2014 at 07:38:05 UTC, Ali Çehreli wrote:
The documentation says that Mutex is a recursive lock, meaning
that the holder of the lock can lock it even further. :) There
is an internal reference count so that the lock must be
unlocked the equal number of times that it has been l
For what it's worth, you can also do:
auto m = new Mutex;
sycnchronized (m) {
// do stuff
}
The synchronized block will call lock on enter and unlock on
exit, even as a result of a throw.
On Monday, 3 March 2014 at 08:18:04 UTC, alexhairyman wrote:
On Monday, 3 March 2014 at 07:38:05 UTC, Ali Çehreli wrote:
On 03/02/2014 10:38 PM, alexhairyman wrote:
> I think I'm missing something big, but I'm having troubles
with mutexes
> (using in a parallel foreach loop somewhere else); Why
On Monday, 3 March 2014 at 07:38:05 UTC, Ali Çehreli wrote:
On 03/02/2014 10:38 PM, alexhairyman wrote:
> I think I'm missing something big, but I'm having troubles
with mutexes
> (using in a parallel foreach loop somewhere else); Why do the
trylocks
> return true shouldn't they return false bec
On 03/02/2014 10:38 PM, alexhairyman wrote:
> I think I'm missing something big, but I'm having troubles with mutexes
> (using in a parallel foreach loop somewhere else); Why do the trylocks
> return true shouldn't they return false because the mutex is already
> locked?
The documentation says t
I think I'm missing something big, but I'm having troubles with
mutexes (using in a parallel foreach loop somewhere else); Why do
the trylocks return true shouldn't they return false because the
mutex is already locked? I don't think this is a phobos bug, I'm
on OSX using dmd 2.065
import cor