MCPcopy Create free account
hub / github.com/Tencent/libco / co_cond_timedwait

Function co_cond_timedwait

co_routine.cpp:1113–1140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111
1112
1113int co_cond_timedwait( stCoCond_t *link,int ms )
1114{
1115 stCoCondItem_t* psi = (stCoCondItem_t*)calloc(1, sizeof(stCoCondItem_t));
1116 psi->timeout.pArg = GetCurrThreadCo();
1117 psi->timeout.pfnProcess = OnSignalProcessEvent;
1118
1119 if( ms > 0 )
1120 {
1121 unsigned long long now = GetTickMS();
1122 psi->timeout.ullExpireTime = now + ms;
1123
1124 int ret = AddTimeout( co_get_curr_thread_env()->pEpoll->pTimeout,&psi->timeout,now );
1125 if( ret != 0 )
1126 {
1127 free(psi);
1128 return ret;
1129 }
1130 }
1131 AddTail( link, psi);
1132
1133 co_yield_ct();
1134
1135
1136 RemoveFromLink<stCoCondItem_t,stCoCond_t>( psi );
1137 free(psi);
1138
1139 return 0;
1140}
1141stCoCond_t *co_cond_alloc()
1142{
1143 return (stCoCond_t*)calloc( 1,sizeof(stCoCond_t) );

Callers 1

ConsumerFunction · 0.85

Calls 6

GetCurrThreadCoFunction · 0.85
GetTickMSFunction · 0.85
AddTimeoutFunction · 0.85
co_get_curr_thread_envFunction · 0.85
AddTailFunction · 0.85
co_yield_ctFunction · 0.85

Tested by

no test coverage detected