mirror of https://github.com/deavmi/dlog.git
parent
b6d002e711
commit
e35f6fba73
|
@ -24,6 +24,16 @@ import std.container.slist : SList;
|
||||||
// import std.range : in;
|
// import std.range : in;
|
||||||
import core.sync.mutex : Mutex;
|
import core.sync.mutex : Mutex;
|
||||||
|
|
||||||
|
// private mixin template Ting(Mutex lock)
|
||||||
|
// {
|
||||||
|
// scope(exit)
|
||||||
|
// {
|
||||||
|
// lock.unlock();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// lock.lock();
|
||||||
|
// }
|
||||||
|
|
||||||
public abstract class Logger
|
public abstract class Logger
|
||||||
{
|
{
|
||||||
private SList!(MessageTransform) transforms;
|
private SList!(MessageTransform) transforms;
|
||||||
|
@ -35,4 +45,30 @@ public abstract class Logger
|
||||||
{
|
{
|
||||||
this.lock = new Mutex();
|
this.lock = new Mutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Handle duplicate?
|
||||||
|
public final void addTransform(MessageTransform transform)
|
||||||
|
{
|
||||||
|
scope(exit)
|
||||||
|
{
|
||||||
|
this.lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lock.lock();
|
||||||
|
|
||||||
|
this.transforms.insertAfter(this.transforms[], transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Hanmdle not found explicitly?
|
||||||
|
public final void removeTransform(MessageTransform transform)
|
||||||
|
{
|
||||||
|
scope(exit)
|
||||||
|
{
|
||||||
|
this.lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lock.lock();
|
||||||
|
|
||||||
|
this.transforms.linearRemoveElement(transform);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue