Hi I have a Command class of type
class Command
{
T* m_objptr;
void (T::*method)();
:
explicit Command(T* pObj,void (T::*p_method)( ),long timeout,const
char* key,long priority = PRIO_NORMAL ):
m_objptr(0),met hod(0),m_timeou t(timeout),m_ke y(key),m_value( priority)
{
m_objptr=pObj;
method = p_method;
}
inline void execute()
{
(m_objptr->*method)();
}
//-----------------------------------------------------------------------
I use this as
cmd= new Command<CTask>( task1,&CTask::D oSomeTask,task1-
where CTask is defined as
class CTask
{
void DoSomeTask()
Question 1
Is this usage safe? ie will &CTask::DoSomeT ask point to the method
of CTask ?
I use this in a threadpool and I am sometimes getting thiings to work
and sometimes access violation (VC6 compiler)
Question 2
Is it possible that I can pass a parameter to the method
something like
class Command
{
T* m_objptr;
void (T::*method)(vo id *);
class CTask
{
void DoSomeTask(void *) or
static void DoSomeTask(void *)
If so how do you initiate Command class - I was getting compiler error
while doing this
cmd= new Command<CTask>( task1,&CTask::D oSomeTask(this) ,task1-
Thanks for your time
Alex.C.P
class Command
{
T* m_objptr;
void (T::*method)();
:
explicit Command(T* pObj,void (T::*p_method)( ),long timeout,const
char* key,long priority = PRIO_NORMAL ):
m_objptr(0),met hod(0),m_timeou t(timeout),m_ke y(key),m_value( priority)
{
m_objptr=pObj;
method = p_method;
}
inline void execute()
{
(m_objptr->*method)();
}
//-----------------------------------------------------------------------
I use this as
cmd= new Command<CTask>( task1,&CTask::D oSomeTask,task1-
>GetTimeOut()," ne2_11"PRIO_NOR MAL);
class CTask
{
void DoSomeTask()
Question 1
Is this usage safe? ie will &CTask::DoSomeT ask point to the method
of CTask ?
I use this in a threadpool and I am sometimes getting thiings to work
and sometimes access violation (VC6 compiler)
Question 2
Is it possible that I can pass a parameter to the method
something like
class Command
{
T* m_objptr;
void (T::*method)(vo id *);
class CTask
{
void DoSomeTask(void *) or
static void DoSomeTask(void *)
If so how do you initiate Command class - I was getting compiler error
while doing this
cmd= new Command<CTask>( task1,&CTask::D oSomeTask(this) ,task1-
>GetTimeOut()," ne2_11"PRIO_NOR MAL);
Alex.C.P
Comment