Home » U++ Library support » U++ MT-multithreading and servers » MT/Locking Questions
MT/Locking Questions [message #15529] |
Mon, 28 April 2008 15:23 |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
This is a general question about using Mutex locking. Does locking occur on a per object basis? what about static variables?
Also, how do locks work in class hierarchies?
For example:
class Parent{
Mutex lock;
String mydata;
virtual void DoSomething(){
for(int i=0;i<10;++i){
Cout() << mydata << "\n;"
}
};
};
class Child1{
void DoSomething(){
INTERLOCKED_(lock){
mydata = "Foo";
Parent::DoSomething();
}
}
};
class Child2{
void DoSomething(){
INTERLOCKED_(lock){
mydata = "Bar";
Parent::DoSomething();
}
}
};
CONSOLE_APP_MAIN{
Parent * c1 = new Child1();
Parent * c2 = new Child2();
Thread().Run(callback(&c1, &Parent::DoSomething);
Thread().Run(callback(&c2, &Parent::DoSomething);
delete c1;
delete c2;
}
Since 2 separate instances of the object are created, both DoSomething()'s can run concurrently, correct?
|
|
|
|
|
MT/Locking Questions
By: captainc on Mon, 28 April 2008 15:23
|
|
|
Re: MT/Locking Questions
By: mirek on Mon, 28 April 2008 19:41
|
|
|
Re: MT/Locking Questions
By: captainc on Mon, 28 April 2008 20:00
|
|
|
Re: MT/Locking Questions
By: mr_ped on Mon, 28 April 2008 20:57
|
|
|
Re: MT/Locking Questions
By: captainc on Mon, 28 April 2008 22:10
|
|
|
Re: MT/Locking Questions
By: mr_ped on Tue, 29 April 2008 10:03
|
|
|
Re: MT/Locking Questions
By: mirek on Tue, 29 April 2008 19:09
|
|
|
Re: MT/Locking Questions
By: mr_ped on Tue, 29 April 2008 21:49
|
|
|
Re: MT/Locking Questions
By: mirek on Wed, 30 April 2008 10:51
|
|
|
Re: MT/Locking Questions
By: mr_ped on Wed, 30 April 2008 16:04
|
|
|
Re: MT/Locking Questions
By: mirek on Wed, 30 April 2008 21:05
|
Goto Forum:
Current Time: Fri Sep 20 04:15:51 CEST 2024
Total time taken to generate the page: 0.02549 seconds
|