 |
|
Posted: 09/06/08 10:35:09
I want to use a class to synchronize on it and call wait() notifyAll() in exactly the same way as in Java?
Is it possiblle to make the class provide this behaviour?
An internal Mutex/Condition pair can be used to get the wait()/notifyAll() methods.
But how can it be made, that synchronizing on the object locks in fact the mutex? Can i set the mutex as the Monitor of class A?
// original
class A : B {
}
// use of A should not need changes
A a = ...;
synchronize(a){
a.notifyAll();
}
// impl for notifyAll, but how make synchronize lock the mutex?
class A : B {
Mutex m; Condition c;
this(){
m = new Mutex;
c = new Condition(m);
}
void notifyAll(){
c.notifyAll();
}
}
|
There are no responses to display.
|
 |
 |
|
 |
Copyright © 2006-2021 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic