Re: is core Mutex lock "fast"?

2021-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/21 4:40 PM, ludo wrote: However, I think this is all moot, druntime is the same as Tango. Moot you mean debatable? Or irrelevant :) I *think* it's irrelevant. The comment makes it sound like it's slightly different than Tango, but for sure reentrant locks are possible with D2 phobos

Re: is core Mutex lock "fast"?

2021-01-26 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 21:09:34 UTC, Steven Schveighoffer wrote: The only item that is read without being locked is owner. If you change that to an atomic read and write, it should be fine (and is likely fine on x86* without atomics anyway). All the other data is protected by the act

Re: is core Mutex lock "fast"?

2021-01-26 Thread ludo via Digitalmars-d-learn
However, I think this is all moot, druntime is the same as Tango. Moot you mean debatable? Or irrelevant :) Thanks to your explanations, I understand now that the dev tried to imitate a Tango feature with very old D1 code. This is 2005/2009 code And as pointed out by IGotD-, better not to me

Re: is core Mutex lock "fast"?

2021-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/21 3:56 PM, IGotD- wrote: That code isn't thread safe at all (assuming FastLock is used from several threads). lockCount isn't atomic which means the code will not work with several threads.> Also the assignment of the variable owner isn't thread safe. As soon you start to include more

Re: is core Mutex lock "fast"?

2021-01-26 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 18:07:06 UTC, ludo wrote: Hi guys, still working on old D1 code, to be updated to D2. At some point the previous dev wrote a FastLock class. The top comment is from the dev himself, not me. My question is after the code. --- class FastLock { protected

Re: is core Mutex lock "fast"?

2021-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/21 1:07 PM, ludo wrote: Hi guys, still working on old D1 code, to be updated to D2. At some point the previous dev wrote a FastLock class. The top comment is from the dev himself, not me. My question is after the code. [snip] Is it so that the old Tango's mutex lock was not keepi

is core Mutex lock "fast"?

2021-01-26 Thread ludo via Digitalmars-d-learn
Hi guys, still working on old D1 code, to be updated to D2. At some point the previous dev wrote a FastLock class. The top comment is from the dev himself, not me. My question is after the code. --- class FastLock { protected Mutex mutex; protected int lockCount; prot