Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSimple UDP Server Pin
Andy2025-Sep-07 5:14
Andy2025-Sep-07 5:14 
AnswerRe: Simple UDP Server Pin
led mike5-Sep-07 5:49
led mike5-Sep-07 5:49 
QuestionHow to protect my vector, or any other variable? Pin
bosfan5-Sep-07 4:25
bosfan5-Sep-07 4:25 
AnswerRe: How to protect my vector, or any other variable? Pin
Waldermort5-Sep-07 4:29
Waldermort5-Sep-07 4:29 
QuestionRe: How to protect my vector, or any other variable? Pin
David Crow5-Sep-07 4:31
David Crow5-Sep-07 4:31 
AnswerRe: How to protect my vector, or any other variable? Pin
bosfan6-Sep-07 1:32
bosfan6-Sep-07 1:32 
GeneralRe: How to protect my vector, or any other variable? Pin
David Crow6-Sep-07 2:09
David Crow6-Sep-07 2:09 
AnswerRe: How to protect my vector, or any other variable? Pin
El Corazon5-Sep-07 4:55
El Corazon5-Sep-07 4:55 
termal wrote:
is it posible to protect environment variable in multithreaded application


Absolutely. The standard answer, is a mutex. Mutual exclusion prevents anything other than one thread from executing through a region of code. A primary way is with CriticalSections. However, it is important to note that you will be accessing the region of code in linear space. That is, you will reduce the code execution for that task to single threaded operation, so you want to make sure it is not your primary occupation of time.

There are other ways, google lock-free algorithms. A good CAS or CAS2 will give you the base structure to build a non-blocking synchronization system, but you will have to think on it. Qt uses something called "implicit sharing" meaning you want to share read access with all threads all the time, but you want to lock it for writing.

You can also use record locking, if you understand how to use a CAS or CAS2 step properly which will allow you to add/change a single vector item and block that one item from reading until the update step is completed, but allow all other reads to all other vector items to continue without delays.

You can also just pull down Intel's thread building blocks and use their threadsafe vector and be done with it all. Wink | ;) http://www.threadingbuildingblocks.org/[^]

_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

QuestionExtracting Zip file stored as BLOB from DB using VC++ Pin
sourav.chats5-Sep-07 4:23
sourav.chats5-Sep-07 4:23 
QuestionNoob seeks help with codecave! [modified] Pin
selkov5-Sep-07 4:07
selkov5-Sep-07 4:07 
AnswerRe: Noob seeks help with codecave! Pin
David Crow5-Sep-07 4:23
David Crow5-Sep-07 4:23 
GeneralRe: Noob seeks help with codecave! Pin
selkov5-Sep-07 4:42
selkov5-Sep-07 4:42 
QuestionHow to use CRichEditCtrl in Ultimate Grid cell? Pin
brazilien5-Sep-07 4:01
brazilien5-Sep-07 4:01 
Questionproblem with WH_MOUSE_LL Pin
josip cagalj5-Sep-07 3:15
josip cagalj5-Sep-07 3:15 
QuestionRe: problem with WH_MOUSE_LL Pin
David Crow5-Sep-07 4:25
David Crow5-Sep-07 4:25 
QuestionHow to set the system time. Pin
chandu0045-Sep-07 1:51
chandu0045-Sep-07 1:51 
AnswerRe: How to set the system time. Pin
jhwurmbach5-Sep-07 2:09
jhwurmbach5-Sep-07 2:09 
AnswerRe: How to set the system time. Pin
Hamid_RT5-Sep-07 5:33
Hamid_RT5-Sep-07 5:33 
Questionconvertin a string into lowercase Pin
neha.agarwal275-Sep-07 1:39
neha.agarwal275-Sep-07 1:39 
AnswerRe: convertin a string into lowercase [modified] Pin
chandu0045-Sep-07 1:45
chandu0045-Sep-07 1:45 
GeneralRe: convertin a string into lowercase Pin
neha.agarwal275-Sep-07 2:02
neha.agarwal275-Sep-07 2:02 
GeneralRe: convertin a string into lowercase Pin
chandu0045-Sep-07 2:07
chandu0045-Sep-07 2:07 
AnswerIs your problem Solved. Pin
chandu0045-Sep-07 1:58
chandu0045-Sep-07 1:58 
QuestionHow to add virtual ip in the windows xp to using c++? songjacky 6hrs 12mins ago Pin
songjacky5-Sep-07 0:53
songjacky5-Sep-07 0:53 
AnswerRe: How to add virtual ip in the windows xp to using c++? songjacky 6hrs 12mins ago Pin
Waldermort5-Sep-07 1:06
Waldermort5-Sep-07 1:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.