|
Hi I am newbie to Multithreading in C++
I have a static shared std::map< std::string >
I am 100% sure that it will be used only READ-ONLY after it has been filled up at startup of the application;
my question is: do I have to use thread synchronization to control the access to it or can I avoid?
Since it is read only, maybe I can skip using a mutex; is this a good idea?
Kind Regards
Manustone
|
|
|
|
|
You can as long as you only read it. Make it a const or with a const accessor function, to ensure it.
Greetings from Germany
|
|
|
|
|
|
Yes reading a container doesn't require synchronization usually.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
|
how to Set Monitor Contrast(0 to 100) using code.....
Plz help
|
|
|
|
|
You may get some hints from here...[^]
- ns ami -
|
|
|
|
|
Thanks for The Link.
But This COde is Setting The Brightness of Monitor but Not Contrast coz boht are Different Terms So i need to CHange the Contrast of Monitor .
Plz help further...
|
|
|
|
|
Hi,
I want to add Picture control Programmatically.Can any one suggest how to do it.Meanwhile I will also search.
I am using following code for creating static control in MFC Dialog.
CStatic * myStatic = new CStatic;
myStatic->Create( _T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(0,0,150,15), NULL );
delete myStatic;
But I am unable to creat it.
|
|
|
|
|
Try using this piece of code.
CStatic * myStatic = new CStatic;
myStatic->Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), this,1);
|
|
|
|
|
Hi,
I tried with the code you have given But no use.Do I need to change any Dialog Properties?
I am using this code in OnInitDialog function of Dialog class.
modified on Tuesday, February 24, 2009 3:08 AM
|
|
|
|
|
What is showing on the screen? is "my static" text displaying on the screen?
|
|
|
|
|
Hi,
It is not showing "my statis".
CStatic * myStatic = new CStatic;
myStatic->Create( _T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(10,10,150,50),this );
After making third line as comment. It is Displaying my static on Dialog.
|
|
|
|
|
dont use delete immediately after creating the static control. It should work for you.
|
|
|
|
|
|
hemlat wrote: After making third line as comment. It is Displaying my static on Dialog.
Well, obviously if you delete the control it won't appear on the screen anymore.
BTW, you don't need to use new for what you are doing. Simply add a CStatic member in your dialog class and call Create when you want the control to be displayed (it has to be a class member, otherwise if it is local to a function, the destructor will be called at the end of the function, removing the control from the screen).
|
|
|
|
|
hemlat wrote: myStatic->Create( _T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(0,0,150,15), NULL );
Give the parent (pParentWnd in Create()) as 'this' insted of NULL.
hemlat wrote: delete myStatic;
You should not delete the myStatic. If do so, static control will be destroyed.
- ns ami -
|
|
|
|
|
thanks for your reply It is displaying.
|
|
|
|
|
Hi All
I am getting Debug Assertion Failed error.Plz help to find why assertion failed.
Error
Debug Assertion Failed in afxwin2.inl line 341
|
|
|
|
|
Post the code where you think the error has occurred.
You could debug your code to get to that point.
hmmm... MS should probably invent a debug point to add to break points and trace points.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
infact Assertion show randomly.And i have no idia where it's occured.
|
|
|
|
|
Well you have a debugger, I suppose. The debugger has some great features, for instance allows you to see the Call Stack list, where you may find the line, of your source code, wherein the error originates.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Look in the file afxwin2.inl line 341 what failed.
And than debug til it occured.
Greetings from Germany
|
|
|
|
|
Have you looked at line 341 of afxwin2.inl to see what condition is asserting? Without doing that, everything is in vain.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I want to use vectors in C++ on a linux box to parse a tab delimited text file and parse something in the second column. In perl I could do something like this:
In perl:
#!/usr/local/bin/perl
while(<>)
{
chomp;
($first_col, $second_col, $third_col)=split(/\t/,$_);
if ($second_col =~ m/$target/g){
print "$second_col\n";
}
}
In C++ I have the following 2 D code, can someone modify it to parse out text in the column 2 using vectors? Thanks for everyones help in advance....
#include <iterator>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
ifstream ff( "test.txt", ios::in );
if ( !ff.is_open() )
return -1;
string name;
vector<string> names;
while( !ff.eof() )
{
ff >> name;
if (!ff.eof())
names.push_back( name );
}
copy (names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
return 0;
} </string></string></vector></string></fstream></iostream></iterator>
|
|
|
|