| 1111 | |
| 1112 | |
| 1113 | int 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 | } |
| 1141 | stCoCond_t *co_cond_alloc() |
| 1142 | { |
| 1143 | return (stCoCond_t*)calloc( 1,sizeof(stCoCond_t) ); |
no test coverage detected