Click here to Skip to main content
15,913,487 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Edit Woes Pin
Stephen Hewitt29-May-06 21:28
Stephen Hewitt29-May-06 21:28 
GeneralRe: Edit Woes Pin
HakunaMatada29-May-06 22:15
HakunaMatada29-May-06 22:15 
GeneralRe: Edit Woes Pin
Stephen Hewitt29-May-06 23:22
Stephen Hewitt29-May-06 23:22 
GeneralRe: Edit Woes Pin
HakunaMatada29-May-06 23:36
HakunaMatada29-May-06 23:36 
QuestionHTML Hooking Pin
HarishDixit28-May-06 19:56
HarishDixit28-May-06 19:56 
AnswerRe: HTML Hooking Pin
Stephen Hewitt29-May-06 15:35
Stephen Hewitt29-May-06 15:35 
GeneralRe: HTML Hooking Pin
Jörgen Sigvardsson30-May-06 10:05
Jörgen Sigvardsson30-May-06 10:05 
GeneralUsing std::queue across two threads Pin
PJ Arends28-May-06 17:22
professionalPJ Arends28-May-06 17:22 
This is probably a dumb question, but I will ask it anyway:->

In my app I am running two threads, the main GUI thread and a data gathering thread. In the application object I have a std::queue object that I am using for data entry. The gathering thread pushes objects into the queue and the the main GUI thread reads and pops the same objects off the queue. My question is do I have to synchronise access to the queue using a critical section or is it perfectly safe to push on one end and pop off the other without worrying about synchronzation? I ask because I want the data gathering thread to be able to run as fast as possible, without having to wait on a critical section while the main thread does it's data accessing.
// CWinApp derived class header file
#define WMU_NEWDATA   WM_APP + 0

#typedef std::queue<CMyDataClass> DataQueue;

class CMyApp : public CWinApp
{
...
DataQueue InputQueue;
...
};

extern CMyApp theApp
// Data gathering thread cpp file
...
CMyDataClass InputData;
...
// fill with data
...
theApp.InputQueue.push(InputData);
theApp.m_pMainWnd->PostMessage(WMU_NEWDATA, 0, 0);
...
// Main Window cpp file
LRESULT CMainFrame::OnNewData(WPARAM, LPARAM)
{
   while (!theApp.InputQueue.empty())
   {
      CMyDataClass NewData = theApp.InputQueue.front();
      theApp.InputQueue.pop();
      // do stuff with the data
   }
}



You may be right
I may be crazy
-- Billy Joel --


Within you lies the power for good, use it!!!
GeneralRe: Using std::queue across two threads Pin
PJ Arends28-May-06 17:50
professionalPJ Arends28-May-06 17:50 
GeneralRe: Using std::queue across two threads Pin
Stuart Dootson28-May-06 23:30
professionalStuart Dootson28-May-06 23:30 
GeneralRe: Using std::queue across two threads Pin
PJ Arends29-May-06 5:58
professionalPJ Arends29-May-06 5:58 
GeneralRe: Using std::queue across two threads Pin
Stuart Dootson29-May-06 11:02
professionalStuart Dootson29-May-06 11:02 
GeneralRe: Using std::queue across two threads Pin
Roger Stoltz30-May-06 0:25
Roger Stoltz30-May-06 0:25 
QuestionCan not insert ATL Simple Object in WTL7.5 with visual studio 2005 Pin
jikanyanwin3228-May-06 3:25
jikanyanwin3228-May-06 3:25 
Questionget Request & Response object Pin
hung_ngole27-May-06 17:24
hung_ngole27-May-06 17:24 
Questionneed help in ADO VC++ Pin
GANsJob26-May-06 18:55
GANsJob26-May-06 18:55 
AnswerRe: need help in ADO VC++ Pin
Milton Karimbekallil27-May-06 1:44
Milton Karimbekallil27-May-06 1:44 
GeneralRe: need help in ADO VC++ Pin
GANsJob28-May-06 19:45
GANsJob28-May-06 19:45 
GeneralRe: need help in ADO VC++ Pin
Milton Karimbekallil29-May-06 2:29
Milton Karimbekallil29-May-06 2:29 
GeneralRe: need help in ADO VC++ Pin
GANsJob1-Jun-06 3:31
GANsJob1-Jun-06 3:31 
QuestionKey handling in a windowless control Pin
TClarke25-May-06 2:41
TClarke25-May-06 2:41 
AnswerRe: Key handling in a windowless control Pin
Stephen Hewitt25-May-06 3:57
Stephen Hewitt25-May-06 3:57 
GeneralRe: Key handling in a windowless control Pin
TClarke25-May-06 6:01
TClarke25-May-06 6:01 
GeneralRe: Key handling in a windowless control [modified] Pin
Stephen Hewitt25-May-06 13:48
Stephen Hewitt25-May-06 13:48 
GeneralRe: Key handling in a windowless control [modified] Pin
TClarke25-May-06 22:49
TClarke25-May-06 22:49 

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.