|
Short answer is no.
Its not any more thread safe than un-file-mapped memory. The only real difference is that
your changes are occasionally flushed to a file, and that it can be reflected in memory
in another process.
On another note, if you are using the mapped memory between processes, then any variables
in it that are pointers are unlikely to be valid in the other process. So a queue may
be dangerous, depending on how you've implemented it.
You can get around the synchronisation problems by using named synch objects in both processes.
Iain.
|
|
|
|
|
hi,
i want help:
i want to make an Address Book for the MS-Outlook to use it from a customized message form.
i made a personal form to send an sms`s using the same form of new message.
any way, the Address Book i`m trying to make is an Address Book that will just show the contacts whom have a mobile phone number in there properties,
will u plz help me, i can`t know where to start from, or how.
thanx alot
i hope to hear from u soon.
|
|
|
|
|
Dear Friends,
Sometime my application gives an error and an abnormal error dialog box gets created and immediately after that my application closes. Also some time my application hungs-up.
I am not able to find out the actual error because usually it never happens but sometime it happens and that is why it is not easy to track errors.
1. Thus please tell me how to create a log file to track of each operation.
2. Also I would like to track few errors like access violation, abnormal error window generation.
As I am also unable to get the exact error so I cannot give any more idea abt errors so it may help if I can create a log file or can track few errors as specified.
Thus please help me to find out the solution.
Also please write to me whether I can make my program to generate a particular error to check whether my preventive measures are working properly.
I am new to VC++ and at present I am unable to find any solution of it. Although I find a function say GetLastError(), but how to use it, to a particular error, I am not getting........I think WM_ENABLE message may also help me in case of hung-up but how to add this message to class wizard?
Thus please help me to find the solution...
Thanking You in advance.
Billar
|
|
|
|
|
|
Hi guys,
I ve got a question, a stupid question maybe...
I m making a DLL, with oviously heaps of functions in it. I would like to have a static variable (something that could be modified my some functions). I was wondering if there is nothing dodgy in creating a static variable in a DLL. Since, I dunno how and when exactly the DLL is loaded and unloaded. Is it reloaded each time a function gets called? It s a bit fuzzy to me.
Maybe there is nothing special in this but I just wanted to be sure..
Thank u 4 ur help...
sysy
|
|
|
|
|
There are ways a DLL can be loaded.
1/ Implicitly. This is the usual way. It happens if you link to the DLL when you are creating
your EXE. When the DLL is loaded, the DllMain function is called, and static variables in
that module (DLL) are initialed. This happens once for each process. See DllMain for
more detail.
2/ Explicitly. This happens at runtime, by the SDK function LoadLibrary.
There are articles on codeproject about DLLs for beginners. I would recommend looking there.
Iain.
|
|
|
|
|
Hi,
Does anyone know what the most efficient method is for copying a large list or vector of data (about 25000 elements)?
cheers,
|
|
|
|
|
I guess that depends on what you mean by copying. If you're talking about duplicating the elements in other list/vector of the same type, then for lists I don't think you can do better than:
std::list<int> l1;
...
std::list<int> l2;
l2=l1; As for vectors, you can be a little smarter:
std::vector<int> v1;
...
std::vector<int> v2;
v2.reserve(v1.size());
v2=v1; Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
cheers Joaquín for replying. Just so I've understood correctly all I need to do is
list1 = list2
and then list1 will have copies of all of the elements in list2 and then any changes I do in either list will not be reflected in the other list? If so this is a lot easier than the method I implemented!!! (I went through the list in a while loop and then copied each element, not very efficient)
thanks,
Andy
|
|
|
|
|
Just so I've understood correctly all I need to do is
list1 = list2
and then list1 will have copies of all of the elements in list2 and then any changes I do in either list will not be reflected in the other list?
Correct.
If so this is a lot easier than the method I implemented!!! (I went through the list in a while loop and then copied each element, not very efficient)
I don't want to dissapoint you, but basically the internals of list1 = list2 do the same kind of loop that you were using, so don't expect any performance improvement
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It works fine when I compile under VC 6.0 but when I convert the project to a VC .NET "solution", the following line will return a NULL pointer:
Code:
CWnd* pWnd = GetParent()->GetDlgItem(edt1);
Any helps? Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
Break the question into steps.
Does GetParent () actually return the window
you are expecting?
Is edt1 still valid? Did you assign a number to
it that no longer matches the ID of the control you are
trying to access?
Is that control actually being created? You can check this
using spy++ etc to see if it (a) exists, and (b) has the
right ID.
Etc.
Iain.
|
|
|
|
|
Hi All,
I am new in vc++.
I would like to send data from one dialog box to one property page.
My question is:-
A property sheet contains two-page (Cpage1 and Cpage 2).
Page1 contains one command button(btnClick) and one text box(nText1).When I press btnClcik , it calls a dialog box(Cdlg) and dialog box contains one text box(nText2) and on Command Button(btnOK).
NOW, I would like to enter integer type value in the text box(ntext2) and then press the btnOK of dialog box.
Then entered value should be shown in the textbox(nText1) of Page1(Cpage).
How to do this.
Regards
Rajesh,
rajesh
|
|
|
|
|
The Cdlg class should have an int member variable. After the call to DoModal() , simply access this member variable. Something like:
class Cdlg : public CDialog
{
public:
int var;
};
page1:onbtnclick()
{
Cdlg dlg;
dlg.DoModal();
int var = dlg.var;
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi !
I'm facing a problem and I'm sure you'll be able to help me !
In my app, I have a class which represents a path (meaning : a path you can follow to go from A to B). This class (Path) is made of any number of Segments, which can be straight or curved.
Thus, apart from the class 'Path', I created a base class called 'Segment' and two classes derived from 'Segment' : 'StraightSergment' and 'ArcSegment'.
The 'Path' class contains a list of 'Segment's.
I want to serialize a Path into a string. Thus, I have a method 'toString' which will in turn call, for each segment, their own 'toString' function. As 'Segment' is an abstract class, it will actually call either 'StraightSegment::toString' or 'ArcSegment::toString'. So far so good.
class Path
{
public:
...
string toString();
void fromString(string Source);
...
private:
list_of_segments MyList;
};
class Segment
{
virtual string toString() = 0;
virtual void fromString(string Source) = 0;
};
class StraightSegment : public Segment
{
string toString();
void fromString(string Source);
};
class ArcSegment : public Segment
{
string toString();
void fromString(string Source);
};
I have a problem when I need to materialize a 'Path' from a string : Before calling 'fromString' function from either 'StraightSegment' or 'ArcSegment', I have to decide which kind of segment it is. Where should I do this ? In the 'Segment' base class ? The problem is that 'Segment' would have to know each classes derived from it. Should I do it into another class ? The problem then would be that the 'Path' class would have to know another class than just 'Segment'.
Well, what do you suggest me ? Which solution is the best ? Are there any better solutions ?
Thank you for your help !
Jerome
|
|
|
|
|
You could have something like:
#include "BootStrap.h"
class Segment
{
...
public:
static Segment *FromString (CString s);
...
protected:
virtual BOOL DoesThisStringMatchMe (CString s) = 0;
virtual BOOL ProcessTheStrings (CString s)
DECLARE_ROOT_CLASS(CBaseFilter)
};
So the Path object knows nothing about different segments.
If you read the article Enumerate your leaf classes it gives
a good explanation of how you can go through each descendant
of Segment
Segment *FromString (CString s)
{
int nType, nTypes = GetRegisteredManufactoringPlantCount();
Segment *pGuess = NULL;
for (nType = 0; nType < nTypes; nType++)
{
CBootStrapper<CBaseFilter>* pBoot = GetRegisteredManufactoringPlant(nIdx);
pGuess = pBoot->CreateObject ();
if (pGuess->DoesThisStringMatchMe (s))
break;
delete pGuess;
pGuess = NULL;
}
if (!pGuess)
return NULL;
pGuess->ProcessString (s);
return pGuess;
}
This hasn't been compiled, obviously, and you'll need to read Jaded Hobos article for
details, but I've used this method in the past. You'll see my comment on his article!
Good luck,
Iain.
|
|
|
|
|
Dear Friends,
Sometime my application gives an error and an abnormal error dialog box generates and then my application shuts down. Some time it may happen that my application hung-up.
Although presently I don't any such kind of error but I would like to track such kind of errors and wish to do some preventive measures accordingly in abnormal cases. Will you please tell me how to track error messages in MFC.
Also please write to me whether I can make my program to generate a particular error to check whether my preventive measures are working properly.
I am new to VC++ and at present I am unable to find any solution for it. Although I find a function say GetLastError(), but how to use it, to a particular error, I am not getting........I think WM_ENABLE message may also help me in case of hung-up but how to add this message to class wizard.
Thus please help me to find the solution...
Thanking You in advance.
Billar
|
|
|
|
|
A quick question.
Does anyone know if a given stl iterator[^], say for a std::vector, remains valid throughout the lifetime of that vector?
I'm having some problem accessing an object stored in a vector via an iterator. The iterator was initialised at at some point in my program, but when I come to access the object through the iterator at a later stage, it fails
To clarify, if I set an iterator like:
vector<obj*>::iterator ite = myvec.begin() + 4;
Will ite , my iterator, remain valid as long as the vector variable is not modified?
I Dream of Absolute Zero
|
|
|
|
|
I think I've sorted my iterator problem. It came down to the smart pointers being to darn smart for its own good and deallocating my objects.
I'd still like an answer to the iterator validity question though!
I Dream of Absolute Zero
|
|
|
|
|
My understanding is that the iterator will be valid as long as the container is unchanged. Once
you change it, all bets are off.
They are equivalent to the old K&R Node * pointing to nodes in a linked list.
But any non-const container member function could mess things up. And it wouldn't be thread
safe, as you may mess things up elsewhere... And so on.
I only ever use iterators locally, but there is no reason your idea shouldn't work if you
are careful.
Iain.
|
|
|
|
|
To clarify, if I set an iterator like:
vector::iterator ite = myvec.begin() + 4;
Will ite, my iterator, remain valid as long as the vector variable is not modified?
Yes, provided you don't insert or delete anything from myvec from the moment you set the value of ite .
With std::list s, on the other hand, iterators remain valid no matter if you insert or delete elements (except if you delete the element the iterator is pointing to, of course.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for confirming that for me.
I Dream of Absolute Zero
|
|
|
|
|
Hello All,
I am getting assertion failed message while runing my application in Win32 debugIU mode:
error message is like this:
Assertion failed
Program: .....\x.exe
file oledisp2.cpp
line: 321
As we know it is vc++ src file. And my application is running properly in Win32 cmrelIU mode. But problem in Win 32 debugIU mode. And that too, same application is running on other PC properly.
What could be the reason? Would you please provide some solution?
Regards,
Jokhan
|
|
|
|
|
Step in through the code and isolate the line shouting Assert.
There is no spoon.
mail
|
|
|
|
|
Have you looked at line 321 of oledisp2.cpp? An unknown type is being used in a call to InvokeHelperV() .
jokhan wrote:
And my application is running properly in Win32 cmrelIU mode. But problem in Win 32 debugIU mode...What could be the reason?
Because the ASSERT() macro will catch program errors only when you are using the debug version of MFC. It will be turned off (and produce no code) when you build your program with the release version of the library.
Don't let the fact that when no errors/messages are produced during the release version of your product that your product is indeed error-free. Whatever condition exists that caused the assertion to fire in the debug version still exists in the release version.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|