src/server/twitmanager.c
static inline int broadcast_twit( struct twitmanager * restrict tm, 
		const char * restrict string, 
		size_t string_len ){
	struct twitpoollist_node *node = NULL;
	int status = 0; // must initialize to zero

	assert( tm != NULL );
	assert( string != NULL );
	assert( string_len != 0 );
	
	// For each registered hearer 
	for ( node = tm->tm_list.tpl_head; node != NULL; node = node->tpln_next ){
		// Must lock the node before storing a twit inside it
		acquire_twitpool( node );
		// Put the twit in the twit pool
		if ( putintwitpool( &node->tpln_twitpool, string, string_len ) == -1 ){
			status = -1;
			break;		
		}
		// Now that the twit is stored in the twitpool signal it
		while ( pthread_cond_signal( &node->tpln_cond, &node->tpln_lock ) ){ continue; }
		// Release the node now
		release_twitpool( node );
	}

	return ( status );
}
// Send the twit to all twit pools
Send the twit to all twit pools
Send the twit to all twit pools
static inline int broadcast_twit( struct twitmanager * restrict tm, 
		const char * restrict string, 
		size_t string_len ){
	struct twitpoollist_node *node = NULL;
	int status = 0; 
	assert( tm != NULL );
	assert( string != NULL );
	assert( string_len != 0 );
	for ( node = tm->tm_list.tpl_head; node != NULL; node = node->tpln_next ){
		acquire_twitpool( node );
		if ( putintwitpool( &node->tpln_twitpool, string, string_len ) == -1 ){
			status = -1;
			break;		
		}
		while ( pthread_cond_signal( &node->tpln_cond, &node->tpln_lock ) ){ continue; }
		release_twitpool( node );
	}
	return ( status );
}
static inline int broadcast_twit ( struct twitmanager * restrict tm , const char * restrict string , size_t string_len ) { struct twitpoollist_node * node = NULL ; int status = 0 ; assert ( tm != NULL ) ; assert ( string != NULL ) ; assert ( string_len != 0 ) ; for ( node = tm -> tm_list . tpl_head ; node != NULL ; node = node -> tpln_next ) { acquire_twitpool ( node ) ; if ( putintwitpool ( & node -> tpln_twitpool , string , string_len ) == -1 ) { status = -1 ; break ; } while ( pthread_cond_signal ( & node -> tpln_cond , & node -> tpln_lock ) ) { continue ; } release_twitpool ( node ) ; } return ( status ) ; }
Send the twit to all twit pools
Send the twit to all twit pools
// must initialize to zero // For each registered hearer  // Must lock the node before storing a twit inside it // Put the twit in the twit pool // Now that the twit is stored in the twitpool signal it // Release the node now