Both shared & local classes, method selection
Etienne via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 29 04:48:41 PDT 2014
Hey,
I'm trying to build a driver for my native event implementation in vibe
(https://github.com/etcimon/event.d/ and
https://github.com/etcimon/vibe.d/blob/native-events/source/vibe/core/drivers/native.d)
I currently have 2 ways of signaling an event loop to wake up, the
AsyncNotifier (event loop is local, this is lock-less) and the
AsyncSignal (event loop in another thread, this one locks).
I must modify LibevManualEvent and rename it to NativeManualEvent in the
native.d file, this class inherits ManualEvent. What I'd like to do is
be able to have :
shared NativeManualEvent m_signal; // uses AsyncSignal as implementation
NativeManualEvent m_notifier; // uses AsyncNotifier as implementation
I'd like to be able to do `static if (is(typeof(this) == shared))` to
implement these two versions differently, but I'm not sure if this event
works or if it is the best way. Ideally, I'd like to have the same class
redefined with and without `shared`. e.g. final shared class
NativeManualEvent; final class NativeManualEvent; so the compiler can
choose the right one.
Is there a defined way of dealing with this problem?
More information about the Digitalmars-d-learn
mailing list