Esempio n. 1
0
//get the first node from the front of the node list
node_t *NextNodeFromList( void ) {
	node_t *node;

	ThreadLock();
	numwaiting++;
	if ( !firstnode ) {
		if ( numwaiting >= GetNumThreads() ) {
			ThreadSemaphoreIncrease( GetNumThreads() );
		}
	} //end if
	ThreadUnlock();

	ThreadSemaphoreWait();

	ThreadLock();

	numwaiting--;

	node = firstnode;
	if ( firstnode ) {
		firstnode = firstnode->next;
		nodelistsize--;
	} //end if
	if ( !firstnode ) {
		lastnode = NULL;
	}

	ThreadUnlock();

	return node;
} //end of the function NextNodeFromList
Esempio n. 2
0
//add the node to the front of the node list
//(effectively using a node stack)
void AddNodeToStack(node_t *node)
{
	ThreadLock();

	node->next = firstnode;
	firstnode = node;
	if (!lastnode) lastnode = node;
	nodelistsize++;

	ThreadUnlock();
	//
	ThreadSemaphoreIncrease(1);
} //end of the function AddNodeToStack
Esempio n. 3
0
//add the node to the end of the node list
//(effectively using a node queue)
void AddNodeToQueue( node_t *node ) {
	ThreadLock();

	node->next = NULL;
	if ( lastnode ) {
		lastnode->next = node;
	} else { firstnode = node;}
	lastnode = node;
	nodelistsize++;

	ThreadUnlock();
	//
	ThreadSemaphoreIncrease( 1 );
} //end of the function AddNodeToQueue