コード例 #1
0
ファイル: CBNode.c プロジェクト: favioflamingo/cbitcoin
void CBDestroyNode(void * vself){
	CBNode * self = vself;
	// Exit thread.
	self->shutDownThread = true;
	CBMutexLock(self->messageProcessMutex);
	if (self->messageQueue == NULL)
		// The thread is waiting for messages so wake it.
		CBConditionSignal(self->messageProcessWaitCond);
	CBMutexUnlock(self->messageProcessMutex);
	CBThreadJoin(self->messageProcessThread);
	CBFreeBlockChainStorage(self->blockChainStorage);
	CBFreeAccounterStorage(self->accounterStorage);
	CBReleaseObject(self->validator);
	CBFreeMutex(self->blockAndTxMutex);
	CBFreeMutex(self->messageProcessMutex);
	CBFreeCondition(self->messageProcessWaitCond);
	CBFreeThread(self->messageProcessThread);
	CBDestroyNetworkCommunicator(vself);
}
コード例 #2
0
ファイル: CBThreadPoolQueue.c プロジェクト: cedrou/cbitcoin
void CBDestroyThreadPoolQueue(CBThreadPoolQueue * self){
	self->shutdown = true;
	for (uint16_t x = 0; x < self->numThreads; x++) {
		CBMutexLock(self->workers[x].queueMutex);
		if (self->workers[x].queue.itemNum == 0)
			// The thread is waiting for items, so wake it.
			CBConditionSignal(self->workers[x].waitCond);
		CBMutexUnlock(self->workers[x].queueMutex);
		CBThreadJoin(self->workers[x].thread);
		CBFreeThread(self->workers[x].thread);
		CBFreeCondition(self->workers[x].waitCond);
		CBFreeMutex(self->workers[x].queueMutex);
		// Free queue
		CBFreeQueue(&self->workers[x].queue, self->destroy);
	}
	CBFreeCondition(self->finishCond);
	CBFreeMutex(self->finishMutex);
	free(self->workers);
}