Click here to Skip to main content
16,016,693 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: inline or macro Pin
CPallini8-Jul-09 21:04
mveCPallini8-Jul-09 21:04 
Questiondifference b/w iterators and indexing for STL Pin
hawk23reddy8-Jul-09 6:32
hawk23reddy8-Jul-09 6:32 
AnswerRe: difference b/w iterators and indexing for STL Pin
minkowski8-Jul-09 6:57
minkowski8-Jul-09 6:57 
AnswerRe: difference b/w iterators and indexing for STL Pin
Stuart Dootson8-Jul-09 7:04
professionalStuart Dootson8-Jul-09 7:04 
QuestionHow to use gotoxy().....? Pin
Razanust8-Jul-09 6:08
Razanust8-Jul-09 6:08 
AnswerRe: How to use gotoxy().....? Pin
Michael Schubert8-Jul-09 6:58
Michael Schubert8-Jul-09 6:58 
AnswerRe: How to use gotoxy().....? Pin
Jijo.Raj8-Jul-09 7:20
Jijo.Raj8-Jul-09 7:20 
Questionnewbie to multi threading Pin
minkowski8-Jul-09 5:45
minkowski8-Jul-09 5:45 
Hi ya,

I am a noob to multi threading on C++ (did a bit on Java) and was hoping you could explain to me the following (from http://www.ddj.com/cpp/184401518?pgno=3).

<br />
<br />
#include <boost/thread/thread.hpp> #include <boost/thread/mutex.hpp> #include <iostream><br />
<br />
boost::mutex io_mutex;<br />
<br />
struct count {<br />
<br />
    count(int id) : id(id) { }<br />
<br />
void operator()()<br />
<br />
{<br />
<br />
     for (int i = 0; i < 10; ++i)<br />
<br />
     {<br />
<br />
                 boost::mutex::scoped_lock lock(io_mutex);<br />
<br />
                 std::cout << id << ": " << i << std::endl;<br />
<br />
     }<br />
<br />
}<br />
<br />
int id;<br />
<br />
};<br />
<br />
int main(int argc, char* argv[])<br />
<br />
{<br />
<br />
    boost::thread thrd1(count(1));<br />
<br />
   boost::thread thrd2(count(2));<br />
<br />
   thrd1.join();<br />
<br />
   thrd2.join();<br />
<br />
  return 0;<br />
<br />
}<br />

what is this for? boost::mutex io_mutex; To say you wish to define a boost::mutex lock and call it io_mutex?

In the for loop a scoped lock is used. Does that mean any object used within the scope of the for loop is locked? Does the lock only lock "this"? How do I lock other objects or do I have to use

a scoped lock in the member function?


Thanks for any information.
AnswerRe: newbie to multi threading Pin
Stuart Dootson8-Jul-09 6:54
professionalStuart Dootson8-Jul-09 6:54 
GeneralRe: newbie to multi threading Pin
minkowski8-Jul-09 7:04
minkowski8-Jul-09 7:04 
GeneralRe: newbie to multi threading Pin
Stuart Dootson8-Jul-09 9:34
professionalStuart Dootson8-Jul-09 9:34 
GeneralRe: newbie to multi threading Pin
minkowski8-Jul-09 22:01
minkowski8-Jul-09 22:01 
GeneralRe: newbie to multi threading Pin
Stuart Dootson9-Jul-09 0:28
professionalStuart Dootson9-Jul-09 0:28 
GeneralRe: newbie to multi threading Pin
minkowski9-Jul-09 0:55
minkowski9-Jul-09 0:55 
GeneralRe: newbie to multi threading Pin
Stuart Dootson9-Jul-09 1:54
professionalStuart Dootson9-Jul-09 1:54 
GeneralRe: newbie to multi threading Pin
minkowski9-Jul-09 2:17
minkowski9-Jul-09 2:17 
GeneralRe: newbie to multi threading Pin
Stuart Dootson9-Jul-09 2:20
professionalStuart Dootson9-Jul-09 2:20 
GeneralRe: newbie to multi threading Pin
minkowski9-Jul-09 2:21
minkowski9-Jul-09 2:21 
GeneralRe: newbie to multi threading Pin
Stuart Dootson9-Jul-09 2:23
professionalStuart Dootson9-Jul-09 2:23 
QuestionRe: CFileDialog, disable "What's This?" menu Pin
mla1548-Jul-09 5:31
mla1548-Jul-09 5:31 
AnswerRe: CFileDialog, disable "What's This?" menu Pin
David Crow8-Jul-09 7:11
David Crow8-Jul-09 7:11 
GeneralRe: CFileDialog, disable "What's This?" menu Pin
mla15410-Jul-09 5:24
mla15410-Jul-09 5:24 
GeneralRe: CFileDialog, disable "What's This?" menu Pin
David Crow10-Jul-09 5:32
David Crow10-Jul-09 5:32 
GeneralRe: CFileDialog, disable "What's This?" menu Pin
mla15410-Jul-09 5:48
mla15410-Jul-09 5:48 
GeneralRe: CFileDialog, disable "What's This?" menu Pin
David Crow10-Jul-09 5:58
David Crow10-Jul-09 5:58 

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.