commit 2025-10-04 14:32 edit a bit ZCppMain/ZCProcess.H
This commit is contained in:
@ -1001,12 +1001,12 @@ namespace ZNsMain
|
|||||||
typename TDataArg =const TSyncData& ,
|
typename TDataArg =const TSyncData& ,
|
||||||
typename TSyncEasy=ZNsMain::ZCCriticSectEasy
|
typename TSyncEasy=ZNsMain::ZCCriticSectEasy
|
||||||
>
|
>
|
||||||
class ZtCSyncObj ////////////////////////////////*/
|
class ZtCSyncObj /////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
/*/////////////////////////////////////////////////////////////////////////////
|
/*/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
■ TMutexCondData 클래스를 상속하여 대기상태에 관련된 2 개의 bool 멤버를 갖는다.
|
■ TMutexCondData 클래스를 상속하여 대기 상태에 관련된 2 개의 bool 멤버를 갖는다.
|
||||||
|
|
||||||
■ TMutexCondData 클래스 타입은 mutex 와 조건변수를 가지고 있어야 한다.
|
■ TMutexCondData 클래스 타입은 mutex 와 조건변수를 가지고 있어야 한다.
|
||||||
|
|
||||||
@ -1020,14 +1020,14 @@ namespace ZNsMain
|
|||||||
typedef TMutexCondData TypeData ;
|
typedef TMutexCondData TypeData ;
|
||||||
typedef TMutexCondData CMutexCondData;
|
typedef TMutexCondData CMutexCondData;
|
||||||
protected:
|
protected:
|
||||||
bool mb_MustWait ;
|
bool mb_MustWait;
|
||||||
bool mb_DoWaitCond;
|
bool mb_WaitCond;
|
||||||
public :
|
public :
|
||||||
|
|
||||||
ZtCMutexCondDataVar()
|
ZtCMutexCondDataVar()
|
||||||
{
|
{
|
||||||
mb_MustWait =false;
|
mb_MustWait= false;
|
||||||
mb_DoWaitCond=false;
|
mb_WaitCond= false;
|
||||||
}/*
|
}/*
|
||||||
ZtCMutexCondDataVar()*/
|
ZtCMutexCondDataVar()*/
|
||||||
|
|
||||||
@ -1039,9 +1039,9 @@ namespace ZNsMain
|
|||||||
{
|
{
|
||||||
if(this->mb_MustWait==true)
|
if(this->mb_MustWait==true)
|
||||||
{
|
{
|
||||||
this->mb_DoWaitCond=true ;
|
this->mb_WaitCond=true ;
|
||||||
this->TMutexCondData::WaitCond();
|
this->TMutexCondData::WaitCond();
|
||||||
this->mb_DoWaitCond=false;
|
this->mb_WaitCond=false;
|
||||||
}/*
|
}/*
|
||||||
if(this->mb_MustWait==true)*/
|
if(this->mb_MustWait==true)*/
|
||||||
}
|
}
|
||||||
@ -1064,22 +1064,22 @@ namespace ZNsMain
|
|||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
else if(this->mb_DoWaitCond==true)
|
else if(this->mb_WaitCond==true)
|
||||||
{
|
{
|
||||||
// 이때는 쓰레드가 잠자고 있다면 깨워야 한다.
|
// 이때는 쓰레드가 잠자고 있다면 깨워야 한다.
|
||||||
|
|
||||||
this->TMutexCondData::WakeCond();
|
this->TMutexCondData::WakeCond();
|
||||||
this->mb_DoWaitCond=false;
|
this->mb_WaitCond=false;
|
||||||
}/*
|
}/*
|
||||||
else if(this->mb_DoWaitCond==true)*/
|
else if(this->mb_WaitCond==true)*/
|
||||||
}
|
}
|
||||||
this->TMutexCondData::UnLock();
|
this->TMutexCondData::UnLock();
|
||||||
}/*
|
}/*
|
||||||
void SetMustWaitBool(bool AB_MustWait)*/
|
void SetMustWaitBool(bool AB_MustWait)*/
|
||||||
|
|
||||||
|
|
||||||
bool MustWait () const{return mb_MustWait ;}
|
bool MustWait () const{return mb_MustWait;}
|
||||||
bool DoWaitCond() const{return mb_DoWaitCond;}
|
bool DoWaitCond() const{return mb_WaitCond;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
};/*
|
};/*
|
||||||
|
@ -4013,8 +4013,8 @@ namespace ZNsMain
|
|||||||
|
|
||||||
// 실험용 코드.
|
// 실험용 코드.
|
||||||
|
|
||||||
bool VB_IsOK1=::pthread_mutex_init(&mh_Mutex, AP_MutexAttr)==ZNsMain::ZNsEnum::ZEThread_OK;
|
bool VB_IsOK1= (::pthread_mutex_init(&mh_Mutex, AP_MutexAttr)==ZNsMain::ZNsEnum::ZEThread_OK);
|
||||||
bool VB_IsOK2=::pthread_cond_init (&mh_Cond, AP_CondAttr )==ZNsMain::ZNsEnum::ZEThread_OK;
|
bool VB_IsOK2= (::pthread_cond_init (&mh_Cond, AP_CondAttr )==ZNsMain::ZNsEnum::ZEThread_OK);
|
||||||
|
|
||||||
return (VB_IsOK1 && VB_IsOK2) ? ZNsMain::ZNsEnum::ZEThread_OK : ZNsMain::ZNsEnum::ZEThread_Invalid ;
|
return (VB_IsOK1 && VB_IsOK2) ? ZNsMain::ZNsEnum::ZEThread_OK : ZNsMain::ZNsEnum::ZEThread_Invalid ;
|
||||||
|
|
||||||
@ -4111,8 +4111,8 @@ namespace ZNsMain
|
|||||||
|
|
||||||
::gettimeofday(&VO_TimeNow, NULL);
|
::gettimeofday(&VO_TimeNow, NULL);
|
||||||
|
|
||||||
VO_TimeAbs.tv_sec =VO_TimeNow.tv_sec + (AI_TimeOutMili/1000) ;
|
VO_TimeAbs.tv_sec = VO_TimeNow.tv_sec + (AI_TimeOutMili/1000) ;
|
||||||
VO_TimeAbs.tv_nsec=VO_TimeNow.tv_usec*1000 + (AI_TimeOutMili%1000)*1000*1000 ;
|
VO_TimeAbs.tv_nsec= VO_TimeNow.tv_usec*1000 + (AI_TimeOutMili%1000)*1000*1000 ;
|
||||||
|
|
||||||
return ::pthread_cond_timedwait(&mh_Cond, &mh_Mutex, &VO_TimeAbs) ; // return ZEThread_TimeOut if timeout
|
return ::pthread_cond_timedwait(&mh_Cond, &mh_Mutex, &VO_TimeAbs) ; // return ZEThread_TimeOut if timeout
|
||||||
}/*
|
}/*
|
||||||
@ -4144,8 +4144,8 @@ namespace ZNsMain
|
|||||||
|
|
||||||
// 실험용 코드.
|
// 실험용 코드.
|
||||||
|
|
||||||
bool VB_IsOK1=::pthread_cond_destroy (&mh_Cond )==ZNsMain::ZNsEnum::ZEThread_OK;
|
bool VB_IsOK1= (::pthread_cond_destroy (&mh_Cond )==ZNsMain::ZNsEnum::ZEThread_OK);
|
||||||
bool VB_IsOK2=::pthread_mutex_destroy(&mh_Mutex)==ZNsMain::ZNsEnum::ZEThread_OK;
|
bool VB_IsOK2= (::pthread_mutex_destroy(&mh_Mutex)==ZNsMain::ZNsEnum::ZEThread_OK);
|
||||||
|
|
||||||
return (VB_IsOK1 && VB_IsOK2) ? ZNsMain::ZNsEnum::ZEThread_OK : ZNsMain::ZNsEnum::ZEThread_Invalid ;
|
return (VB_IsOK1 && VB_IsOK2) ? ZNsMain::ZNsEnum::ZEThread_OK : ZNsMain::ZNsEnum::ZEThread_Invalid ;
|
||||||
|
|
||||||
|
@ -2364,9 +2364,8 @@ namespace ZNsMain
|
|||||||
::InitializeConditionVariable(&mo_CondVar);
|
::InitializeConditionVariable(&mo_CondVar);
|
||||||
|
|
||||||
if(::InitializeCriticalSectionEx(&mo_CritSect, ESpinCount, 0)==TRUE)
|
if(::InitializeCriticalSectionEx(&mo_CritSect, ESpinCount, 0)==TRUE)
|
||||||
return ZNsEnum::ZEThread_OK;
|
return ZNsEnum::ZEThread_OK ;
|
||||||
else
|
else return ZNsEnum::ZEThread_Invalid;
|
||||||
return ZNsEnum::ZEThread_Invalid;
|
|
||||||
}/*
|
}/*
|
||||||
int InitCond()*/
|
int InitCond()*/
|
||||||
|
|
||||||
@ -2423,7 +2422,7 @@ namespace ZNsMain
|
|||||||
class ZtCMutexCondData : public TData */
|
class ZtCMutexCondData : public TData */
|
||||||
|
|
||||||
|
|
||||||
#else // !(defined(__VISUAL_CPP_VER__) && __VISUAL_CPP_VER__>=200800)
|
#else // !( defined(__VISUAL_CPP_VER__) && __VISUAL_CPP_VER__>=200800 )
|
||||||
|
|
||||||
|
|
||||||
template< typename TData=ZNsMain::ZCEmpty
|
template< typename TData=ZNsMain::ZCEmpty
|
||||||
@ -2497,8 +2496,8 @@ namespace ZNsMain
|
|||||||
}/*
|
}/*
|
||||||
if(mb_IsOnWait==false)*/
|
if(mb_IsOnWait==false)*/
|
||||||
|
|
||||||
DWORD VI_Return = ::SignalObjectAndWait(
|
DWORD VI_Return = ::SignalObjectAndWait
|
||||||
mh_MutexSync, mh_EventWait, ADW_TimeOut, FALSE);
|
( mh_MutexSync, mh_EventWait, ADW_TimeOut, FALSE );
|
||||||
|
|
||||||
#if(_CODE_BAD_)
|
#if(_CODE_BAD_)
|
||||||
return (VI_Return==WAIT_OBJECT_0) ? Lock() : VI_Return;
|
return (VI_Return==WAIT_OBJECT_0) ? Lock() : VI_Return;
|
||||||
|
Reference in New Issue
Block a user