std.experimental.logger formal review round 3
Robert burner Schadek via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 30 06:41:42 PST 2014
On Saturday, 29 November 2014 at 19:18:01 UTC, Martin Nowak wrote:
> On 11/29/2014 05:25 PM, Robert burner Schadek wrote:
>>
>> Yes, there is a lock free, thread local indirection now. That
>> can be
>> used to build a lock free, thread local logger.
>>
>> p.s. You should have taken the phun
>
> I commented on the relevant commit.
> https://github.com/burner/phobos/commit/8a3aad5df5218bd995d4679f9b59a59909969b52#diff-59d32a64bcbd4492ff85f10091d73f5fR289
I missed that final.
>
> Let me propose a light-weight alternative solution.
>
> ```d
> abstract class Logger
> {
> Object.Monitor mutex;
>
> this()
> {
> this.mutex = createMutex();
> }
>
> Object.Monitor createMutex()
> {
> import core.sync.mutex;
> return new Mutex;
> }
> }
> ```
>
> This allows people to override the mutex with whatever fits
> their bill, e.g. one that supports fiber suspension. Especially
> they can do this.
>
> Object.Monitor createMutex()
> {
> static class NoLock : Object.Monitor
> {
> void lock() nothrow {}
> void unlock() nothrow {}
> }
> return new NoLock;
> }
I will add this and remove the final.
Thank you
More information about the Digitalmars-d
mailing list