Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » MT/Locking Questions
Re: MT/Locking Questions [message #15599 is a reply to message #15591] Wed, 30 April 2008 10:51 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mr_ped wrote on Tue, 29 April 2008 15:49

I bet this info is nowhere in Docs, isn't it? Very Happy
(didn't find it trough Search on this site: "Mutex -forum")

Edit:
So if I understand you correctly, as long as I don't USE the Mutex in init block, I can freely use "static Mutex some_lock;", right?
If I am sure it will be initialized before I will try to use it, i.e. I will use it only outside of ctors after the application is started, that is.


Unfortunately, not.

At least, you cannot use it in function body. The problem is that static initialization itself is NOT MT safe.

So e.g.

void Fn()
{
static Mutex x;
}

would make Fn require external locking, because two threads might race when checking that flag used to implement static initialization.

Mirek

P.S.: Oh I guess you have in fact covered this issue in your post....

[Updated on: Wed, 30 April 2008 10:58]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to send broadcast
Next Topic: PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP not defined
Goto Forum:
  


Current Time: Thu Mar 28 13:10:02 CET 2024

Total time taken to generate the page: 0.01184 seconds