Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Communication DLL C# et DLL C++ Pin
Joe Woodbury25-Jul-09 16:05
professionalJoe Woodbury25-Jul-09 16:05 
GeneralRe: Communication DLL C# et DLL C++ Pin
wislamOS25-Jul-09 16:21
wislamOS25-Jul-09 16:21 
GeneralRe: Communication DLL C# et DLL C++ Pin
harold aptroot25-Jul-09 16:31
harold aptroot25-Jul-09 16:31 
GeneralRe: Communication DLL C# et DLL C++ Pin
Joe Woodbury25-Jul-09 16:41
professionalJoe Woodbury25-Jul-09 16:41 
GeneralRe: Communication DLL C# et DLL C++ Pin
Richard Andrew x6425-Jul-09 17:13
professionalRichard Andrew x6425-Jul-09 17:13 
GeneralRe: Communication DLL C# et DLL C++ Pin
Joe Woodbury25-Jul-09 17:21
professionalJoe Woodbury25-Jul-09 17:21 
AnswerRe: Communication DLL C# et DLL C++ Pin
Randor 25-Jul-09 22:36
professional Randor 25-Jul-09 22:36 
QuestionData integrity question. Pin
Ahmed Charfeddine25-Jul-09 13:36
Ahmed Charfeddine25-Jul-09 13:36 
I have a reader that reads an int
and I have a writer that modifies that int.

In other words I have an int called iVal :
int iVal;


And I have a thread A that constantly reads iVal and another different thread B that, sometimes modifies the value of iVal.

My concern is with problems that may arise when A is reading iVal at the same time B is modifying it.

I used to rely on InterlockedIncrement,etc whenever I have the scenario of two writers for the same variable.

But what if my writer (B) could do more than a simple incrementation and that my readers must read the value as it is just before the writer could modify it or as it is just after it would be modified ?

I'm not sure already that the depicted scenario is unsafe. It data incorrectness could happen and cause the reader to behave in unplanned way. Moreover I seek a simple way without introducing a critical section for iVal variable :

Ie I want to avoid having to wrap the simple iVal into a class and do things like the following :
Class CValue{
private :
CCRITICAL_SECTION cs;
int iVal;
public:
CValue()
{
InitializeCriticalSection(&cs);
}
~CValue()
{
DeleteCriticalSection(&cs);
}
void setValue(int iVal)
{
EnterCriticalSection(&cs);
this->iVal = iVal;
LeaveCriticalSection(&cs);
}
int getValue()
{
int _iVal;
EnterCriticalSection(&cs);
_iVal = iVal;
LeaveCriticalSection(&cs);
return _iVal;
}
}


Thank you..in advance.

Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com

AnswerRe: Data integrity question. Pin
Joe Woodbury25-Jul-09 15:58
professionalJoe Woodbury25-Jul-09 15:58 
QuestionLimiting a Window's Size Pin
Steve Thresher25-Jul-09 7:07
Steve Thresher25-Jul-09 7:07 
AnswerRe: Limiting a Window's Size Pin
Code-o-mat25-Jul-09 7:38
Code-o-mat25-Jul-09 7:38 
GeneralRe: Limiting a Window's Size Pin
Steve Thresher25-Jul-09 10:59
Steve Thresher25-Jul-09 10:59 
QuestionSecond short, easy program with harmonic average, works, but need coments... Pin
zutautas25-Jul-09 7:00
zutautas25-Jul-09 7:00 
QuestionShort, easy program, dont work properly. Pin
zutautas25-Jul-09 1:48
zutautas25-Jul-09 1:48 
AnswerRe: Short, easy program, dont work properly. Pin
Rajesh R Subramanian25-Jul-09 2:19
professionalRajesh R Subramanian25-Jul-09 2:19 
GeneralRe: Short, easy program, dont work properly. Pin
Stephen Hewitt25-Jul-09 3:25
Stephen Hewitt25-Jul-09 3:25 
GeneralRe: Short, easy program, dont work properly. Pin
CPallini25-Jul-09 3:36
mveCPallini25-Jul-09 3:36 
GeneralRe: Short, easy program, dont work properly. Pin
zutautas25-Jul-09 3:47
zutautas25-Jul-09 3:47 
GeneralRe: Short, easy program, dont work properly. Pin
CPallini25-Jul-09 5:57
mveCPallini25-Jul-09 5:57 
GeneralRe: Short, easy program, dont work properly. Pin
zutautas25-Jul-09 6:53
zutautas25-Jul-09 6:53 
GeneralRe: Short, easy program, dont work properly. Pin
CPallini25-Jul-09 9:28
mveCPallini25-Jul-09 9:28 
GeneralRe: Short, easy program, dont work properly. Pin
Rajesh R Subramanian25-Jul-09 6:47
professionalRajesh R Subramanian25-Jul-09 6:47 
QuestionJunk characters appearing after writing buffer to file Pin
kool_harsh25-Jul-09 0:09
kool_harsh25-Jul-09 0:09 
AnswerRe: Junk characters appearing after writing buffer to file Pin
Randor 25-Jul-09 22:51
professional Randor 25-Jul-09 22:51 
GeneralRe: Junk characters appearing after writing buffer to file Pin
kool_harsh27-Jul-09 20:00
kool_harsh27-Jul-09 20:00 

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.