synchronized (this[.classinfo]) in druntime and phobos
Christophe Travert
travert at phare.normalesup.org
Sat Jun 9 11:54:57 PDT 2012
deadalnix , dans le message (digitalmars.D:169136), a écrit :
> It open door for stuff like :
> ReadWriteLock rw;
> synchronized(rw.read) {
>
> }
>
> synchronized(rw.write) {
>
> }
>
> And many types of lock : spin lock, interprocesses locks, semaphores, .
> . . And all can be used with the synchronized syntax, and without
> exposing locking and unlocking primitives.
>
synchronize (foo) { ... } could do anything.
You might as well propose a syntax sugar to call any function or method
taking a delegate. You could make it do any operation with the idiom:
struct MyType {
void foo(void delegate() dg) {
this.open();
scope(exit) this.close();
dg();
}
...
}
a.foo { // maybe some keyword should be necessary
...
}
Same problem as opApply, should take different type of delegates, etc...
More information about the Digitalmars-d
mailing list