|
are the threads modifying this shared object ?
if so, you will at least need to synchronize access to the object - to make sure one thread isn't reading while another thread is writing. but it's impossible for us to say if threads will all need their own copy or not, without knowing what the threads are doing to the object.
if they are just reading from the object, they can probably all share one instance.
|
|
|
|
|
For critical sections, #pragma omp single can be used as barriers.
In a parallel region, there are often sections of code where limiting access to a single thread is desired,
such as when writing to a file in the middle of a parallel region.
In many of these cases it does not matter which thread executes this code,
as long as it is just one thread. OpenMP has #pragma omp single to do this.
#pragma omp parallel
{
if(omp_get_thread_num() > 3)
{
#pragma omp single // May not be accessed by all threads
x++;
}
}
OpenMP features for multithreaded applications
http://msdn.microsoft.com/en-us/magazine/cc163717.aspx
|
|
|
|
|
I have a simple MFC application. I would like to save ths position (coordinates) of my application into the registry, so it can remember it's position the next time I launch.
When I launch, I am using SetWindowPos(x,y,cx,cy). I am also doing theApp.m_pMainWnd->GetWindowPlacement( ) when I close the app to get the coordinates and save them to registry. But when I launch back, it isn't in the same position.
Is GetWindowPlacement( ) not the right call in this case?
|
|
|
|
|
|
oops, I forgot to do (right - left) and (bottom - top) in my WindowSetPos().... this will do it.
|
|
|
|
|
How can i resize my controls when i resize my Dialogue
is there any method to achieve this automatically ....
thanks in advance
|
|
|
|
|
No, you have to do it manually. However, if you are using MFc (but it seems not the case because you specified win32), there are some articles on codeproject which provide helper classes to do so. I don't know if you'll be able to find something similar for win32.
|
|
|
|
|
thanks Cedric
No MFC wont help me. I try to find some solution for win32
|
|
|
|
|
|
In response to WM_INITDIALOG , call GetClientRect() to get the dialog's initial size.
In response to WM_GETMINMAXINFO , set the minimum size of the dialog. If nothing else, you can use the values returned from GetClientRect() , but you might also want to consider frame and caption sizes.
In response to WM_SIZE , resize each control that is affected by the dialog's new size.
It's MFC, but I show how to do this here and here.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
I would recommend EasySize[^] by Marc Richarme[^]. I have used it in many projects over the years.
Its an absolute Meisterstück.
Best Wishes,
-David Delaune
|
|
|
|
|
Does it work with Win32 or is it MFC only ?
Watched code never compiles.
|
|
|
|
|
Well the version I am using supports both Win32 and MFC. I think I downloaded it from one of the article comments several years back. Looks like the article was geared towards MFC.
Best Wishes,
-David Delaune
|
|
|
|
|
You might want to remove the extraneous dot in those two URLs.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi DavidCrow,
Actually the trailing dot at the end of the URI is correct. It is called the root zone and is described in RFC-1034[^]. I come from a Unix backgound and have always written my URI with the DNS root zone. It is only recently within the last 2-3 years that I have noticed that certain browsers and webservers cannot handle the DNS root zone being present in the URI. I guess their 20 year old software engineers forgot to read RFC-1034.
Maybe I am just getting old. I guess the next thing that will dissapear will be the HTTP:// protocol indicator.
Best Wishes,
-David Delaune
|
|
|
|
|
I've never seen such a dot used. I can't get those URLs to work with IE or FF.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
Randor wrote: What version of IE and FF are you using?
8 and 3, respectively.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi Friends,
I am using CListCtrl all images display on the first column, but i expect a output on second column,i don't know how to display on second column. please help me.Here is my sample code for first columns image dispaly.
Code..
m_SmallImg.Create(IDB_BITMAP2, 16, 1, RGB(255, 255, 255));
m_SmallImg1.Create(IDB_BITMAP1, 16, 1, RGB(255, 255, 255));
m_List->SetBkColor(RGB(66,66,66));
m_List->SetTextColor(RGB(255,255,255));
m_List->SetTextBkColor(RGB(66,66,66));
m_List->SetOutlineColor(RGB(255,0,0));
for(int i=0;i<=6;i++)
{
LVITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
lvItem.iItem = i;
lvItem.iSubItem = 0;
lvItem.iImage = i % 2;
lvItem.pszText = " sModelName ";
i = m_List->InsertItem(&lvItem);
m_List->SetItemText(i, 1, " TagName ");
m_List->SetItemText(i, 2, " UserName ");
m_List->SetItemText(i, 3, " Descddfgdfgfggdf ");
}
|
|
|
|
|
|
Hi,
I have a doubt regarding multimap::equal_range function for the following program.
int main ()
{
multimap<char,int> mymm;
multimap<char,int>::iterator it,it1,it2;
pair<multimap<char,int>::iterator,multimap<char,int>::iterator> ret;
mymm.insert(std::pair<const char,int>('a',10));
mymm.insert(std::pair<const char,int>('b',20));
mymm.insert(std::pair<const char,int>('b',30));
mymm.insert(std::pair<const char,int>('c',40));
mymm.insert(std::pair<const char,int>('b',50));
mymm.insert(std::pair<const char,int>('c',60));
mymm.insert(std::pair<const char,int>('d',70));
cout << "mymm contains:\n";
for (char ch='a'; ch<='d'; ch++)
{
cout << ch << " =>";
ret = mymm.equal_range(ch);
it1 = ret.first;
it2 = ret.second;
cout << (*it1).second << " " << (*it2).second << endl;
for (it=ret.first; it!=ret.second; ++it)
cout << " " << (*it).second;
cout << endl;
}
return 0;
}
It is giving following output:
mymm contains:
a =>10 20
10
b =>20 40
20 30 50
c =>40 70
40 60
d =>70 70
What I am not getting is the o/p for 'b'. I think it should be
b =>20 60
20 30 50
Please revert.
BR,
Akash
|
|
|
|
|
The output is correct, the map is orderd by the key.
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]
|
|
|
|
|
Some suggestions:
- Use
typedef s:
typedef multimap<char,int> char2int;
typedef char2int::iterator char2map_it;
char2map mymm;
char2map_it it,it1,it2;
pair<char2map_it, char2map_it> ret;
There's no need to repeat long type names all over the place. One design decision should, if possible, be expressed in one place (or as few as possible): Now I can change from a map from char s to int s to a map from char s to std::string s by changing one line, for example.
- Use
make_pair from #include <utility> :
mymm.insert(make_pair('a', 10));
None of this is related to your question...
Steve
|
|
|
|
|
hi friends,
class MyEchoSocket : public CAsyncSocket
{
public:
virtual void OnAccept(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnConnect(int nErrorCode);
virtual void OnOutOfBandData(int nErrorCode);
virtual void OnReceive(int nErrorCode);
virtual void OnSend(int nErrorCode);
};
class CServerDlg : : public CDialog
{
public:
void OnReceive();
void OnClose();
void OnAccept();
void OnSent();
CSolusServerDlg(CWnd* pParent = NULL); // standard constructor
};
void CServerDlg::OnAccept()
{
CString strIP;
UINT port;
if(m_sListener.Accept(m_sConnected))
{
m_sConnected.GetPeerName(strIP,port);
m_status = strIP ;
UpdateData(FALSE);
}
else
{
AfxMessageBox("Cannot Accept Connection");
}
}
this above code is crasing 2nd client accepting or multiple client trying to connect
please help me...
|
|
|
|
|
Member 3653751 wrote: this above code is crasing...
Which is fairly meaningless given that you've provided no context, or stated exactly what is happening. By "crash" do you mean an exception is thrown, an assertion is fired, or something else? Please elaborate. Have you used the debugger to narrow the problem down?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|