jweller
June 15th, 2004, 08:27 AM
I am constantly running into the following problem. Suppose I have a class with a HANDLE.
class T
{
HANDLE handle;
T()
T(const T & t)
~T ()
}
T::T()
{
handle = CreateEvent (NULL, TRUE, TRUE, NULL);
}
T::T(const T & t)
{
// What do you do here?
// Copy the handle from t?
handle = t.handle;
// Create a new handle?
handle = CreateEvent (NULL, TRUE, TRUE, NULL);
// Ideally, you assign the handle from t and increment the OS
// handle count. I don't see how you do this. Is there a way?
::DuplicateHandle () doesn;t seem to work
}
T:~:T()
{
CloseHandle (handle);
}
This problem is further compounded when using STL and you push the object into a container. You get temporarary copies, etc.
What can be done? I don't want event object I create to be on the heap.
Any ideas?
Thanks,
Jim
class T
{
HANDLE handle;
T()
T(const T & t)
~T ()
}
T::T()
{
handle = CreateEvent (NULL, TRUE, TRUE, NULL);
}
T::T(const T & t)
{
// What do you do here?
// Copy the handle from t?
handle = t.handle;
// Create a new handle?
handle = CreateEvent (NULL, TRUE, TRUE, NULL);
// Ideally, you assign the handle from t and increment the OS
// handle count. I don't see how you do this. Is there a way?
::DuplicateHandle () doesn;t seem to work
}
T:~:T()
{
CloseHandle (handle);
}
This problem is further compounded when using STL and you push the object into a container. You get temporarary copies, etc.
What can be done? I don't want event object I create to be on the heap.
Any ideas?
Thanks,
Jim