std.experimental.logger formal review round 3

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 29 04:02:22 PDT 2014


The thread-safety changes in short: Every Logger is now taking
a lock when a public method is invoked and then calls the user
overridable methods with the lock taken.

* When you implement a new logger, thread-safety is already
  taken care of.
* Taking a lock in a single-threaded context is practically
  free compared to the actual logging. (So don't worry.)
* It is not possible to enter a Logger with multiple threads
  and provide more fine-grained thread synchronization. In
  particular only one thread at a time can call a global log
  function like `debug(...)` or `error(...)`.

Note: This is different from the original intention to have
Loggers implement thread safety if they need it and a stopgap
measure looking for use cases that need modifications.

--
Marco


More information about the Digitalmars-d mailing list