Click here to Skip to main content
15,908,173 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 20:37
SAMZC15-Oct-10 20:37 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
Rick York18-Oct-10 7:11
mveRick York18-Oct-10 7:11 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC18-Oct-10 18:22
SAMZC18-Oct-10 18:22 
AnswerRe: One genneral question on dual buffers design with multi-threading Pin
Rajesh R Subramanian15-Oct-10 1:05
professionalRajesh R Subramanian15-Oct-10 1:05 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 20:53
SAMZC15-Oct-10 20:53 
AnswerRe: One genneral question on dual buffers design with multi-threading Pin
federico.strati15-Oct-10 1:40
federico.strati15-Oct-10 1:40 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 20:51
SAMZC15-Oct-10 20:51 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZCN15-Oct-10 23:31
SAMZCN15-Oct-10 23:31 
I read the CDoubleBuffer class you write. It's a very good implementation on the double buffer usage. Here I have some questions on the buffer class. Would you please give some comments?Thanks in advance.
1. Is it thread-safe of CDoubleBuffer? In Read/Write function, each of them will access the target buffer.If in multi-thread case, the reader thread will use Read() and the writer thread will use Write() simutaneously. Both of the function will access unRead/unWrite variables. Is it necessary to declare the variable with key word of volatile?
2. About the CCircBuffer, I have the same question of CDoubleBuffer. Besides, what's the purpose of the following two functions?
// Increment the read pointer
UINT32 IncTheReadPtr(void);
// Increment the write pointer
UINT32 IncTheWritePtr(void);

From the implemention of the two funcitons, I see it does nothing except only increasing the pointer. And the pointer increasement has been done in GetTheData()/SetTheData() functions.

Appreciated for your share. It's very usefull for me to understand the problem of my case furthermore. And I get big confidence to start my job on this case.
federico.strati wrote:
#ifndef DOUBLE_BUFFER_H
#define DOUBLE_BUFFER_H

#include <afx.h>
#include <afxwin.h>

class CDoubleBuffer
{
public:
CDoubleBuffer( unsigned int unAlloc = 0x000FFFFF );
~CDoubleBuffer(void);

void Write(void* pBuf, unsigned int unBytesTo);
void Read (void* pBuf, unsigned int unBytesFrom);

private:
void** pAlloc;
unsigned int unRead;
unsigned int unWrite;
unsigned int unSize;
};

#endif // ! defined (DOUBLE_BUFFER_H)

GeneralRe: One genneral question on dual buffers design with multi-threading Pin
federico.strati17-Oct-10 20:45
federico.strati17-Oct-10 20:45 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC16-Oct-10 7:57
SAMZC16-Oct-10 7:57 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
federico.strati17-Oct-10 20:50
federico.strati17-Oct-10 20:50 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZCN18-Oct-10 2:16
SAMZCN18-Oct-10 2:16 
GeneralRe: One genneral question: there were errors in my code !!! Pin
federico.strati19-Oct-10 22:25
federico.strati19-Oct-10 22:25 
QuestionHello calling function between two different processes Pin
nah133714-Oct-10 22:42
nah133714-Oct-10 22:42 
AnswerRe: Hello calling function between two different processes Pin
CPallini14-Oct-10 22:47
mveCPallini14-Oct-10 22:47 
AnswerRe: Hello calling function between two different processes Pin
Rajesh R Subramanian15-Oct-10 0:52
professionalRajesh R Subramanian15-Oct-10 0:52 
QuestionEncrypt / Decrypt a file Pin
mesajflaviu14-Oct-10 21:51
mesajflaviu14-Oct-10 21:51 
AnswerRe: Encrypt / Decrypt a file Pin
CPallini14-Oct-10 22:32
mveCPallini14-Oct-10 22:32 
Questionstring question Pin
sadas232341s14-Oct-10 8:20
sadas232341s14-Oct-10 8:20 
AnswerRe: string question Pin
Luc Pattyn14-Oct-10 8:36
sitebuilderLuc Pattyn14-Oct-10 8:36 
QuestionRe: string question Pin
David Crow14-Oct-10 9:15
David Crow14-Oct-10 9:15 
AnswerRe: string question Pin
CPallini14-Oct-10 9:27
mveCPallini14-Oct-10 9:27 
GeneralRe: string question Pin
Luc Pattyn14-Oct-10 9:34
sitebuilderLuc Pattyn14-Oct-10 9:34 
GeneralRe: string question Pin
CPallini14-Oct-10 9:39
mveCPallini14-Oct-10 9:39 
Questionwhat does these lines mean?? Pin
AmbiguousName14-Oct-10 3:42
AmbiguousName14-Oct-10 3:42 

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.