TEST_F(putFixture, multiPut) { int NUMBER_OF_PUTS = 1000; char* data = "testput"; for (int i = 0; i < NUMBER_OF_PUTS; i++) { curly_http_transaction_handle handle = curly_http_put("http://httpbin.org/put", data, strlen(data), &onHttpRequestCompleted); } WAITUNTIL(35000, completedSuccessfullTransfers == NUMBER_OF_PUTS); }
static isc_threadresult_t #ifdef _WIN32 /* XXXDCL */ WINAPI #endif run(void *uap) { isc__timermgr_t *manager = uap; isc_time_t now; isc_result_t result; LOCK(&manager->lock); while (!manager->done) { TIME_NOW(&now); XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_RUNNING, "running"), now); dispatch(manager, &now); if (manager->nscheduled > 0) { XTRACETIME2(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_WAITUNTIL, "waituntil"), manager->due, now); result = WAITUNTIL(&manager->wakeup, &manager->lock, &manager->due); INSIST(result == ISC_R_SUCCESS || result == ISC_R_TIMEDOUT); } else { XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_WAIT, "wait"), now); WAIT(&manager->wakeup, &manager->lock); } XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, ISC_MSG_WAKEUP, "wakeup")); } UNLOCK(&manager->lock); #ifdef OPENSSL_LEAKS ERR_remove_state(0); #endif return ((isc_threadresult_t)0); }
/** * Wait on semaphore. This operation will try to acquire a lock on the * semaphore. If the semaphore is already acquired as many times at it allows, * the function will block until someone releases the lock OR timeout expires. * * @return ISC_R_SUCCESS or ISC_R_TIMEDOUT or other errors from ISC libs */ isc_result_t semaphore_wait_timed(semaphore_t *const sem, const isc_interval_t * const timeout) { isc_result_t result; isc_time_t abs_timeout; REQUIRE(sem != NULL); CHECK(isc_time_nowplusinterval(&abs_timeout, timeout)); LOCK(&sem->mutex); while (sem->value <= 0) CHECK(WAITUNTIL(&sem->cond, &sem->mutex, &abs_timeout)); sem->value--; cleanup: UNLOCK(&sem->mutex); return result; }
bool TallyVotes::vote( unsigned int id, bool ballot ) { vote_total += ballot; if (num_voting >= group_size) { signal_flag = true; printer.print(id, Voter::Complete); } else { signal_flag = false; } WAITUNTIL ( signal_flag, printer.print(id, Voter::Block, ++num_voting), printer.print(id, Voter::Unblock, --num_voting)); bool result = ((vote_total * 2)/group_size > 0) ? true : false; if (num_voting <= 0) vote_total = 0; return result; }
TEST_F(putFixture, singlePut) { char* data = "testput"; curly_http_transaction_handle handle = curly_http_put("http://httpbin.org/put", data, strlen(data), &onHttpRequestCompleted); WAITUNTIL(3000, lastHttpRequestStatus == 200); }