src/server/statistics.c
void *statisticsUpdater( void *arg ){
	struct serverinfo *si = ( struct serverinfo * )arg;
	float averageTwitsIncomingRate = 0.0;
	float averageTwitsOutcomingRate = 0.0;

	assert( si != NULL );

	// At first inform that preparation is over and successfull.
	signal_prepared_status( si, 1 );

	// Every STATS_UPDATE_NSEC seconds 
	while ( 1 ){
		sleep( STATS_UPDATE_NSEC );
		// Update the statistics structure
		acquire_statistics( si );
		averageTwitsIncomingRate = si->si_stats.stats_averageTwitsIncomingRate = 
			( averageTwitsIncomingRate + si->si_stats.stats_arrivedTwitsNum ) / 2;
		averageTwitsOutcomingRate = si->si_stats.stats_averageTwitsOutcomingRate = 
			( averageTwitsOutcomingRate + si->si_stats.stats_deliveredTwitsNum ) / 2;
		release_statistics( si );
	}

	pthread_exit( NULL );
}
/**
 * statisticsUpdater() runs on its own thread that is responsible for updating the statistics member 
 * of the serverinfo structure that is passed as parameter. 
 * Most of the fields in the statistics structure are handled by other threads; for example 
 * when sayersListener() accepts a new connection from a sayer the member stats_sayersNum is increased
 * by one by sayersListener(). 
 * The only members that cannot be changed by the other threads and *must* be updated every some time unit
 * are stats_averageTwitsIncomingRate and stats_averageTwitsOutcomingRate. The time unit is obtained
 * from config.h (STATS_UPDATE_NSEC). The statisticsUpdater() function updates those two fields every
 * STATS_UPDATE_NSEC seconds.
 */
statisticsUpdater() runs on its own thread that is responsible for updating the statistics member
of the serverinfo structure that is passed as parameter.
Most of the fields in the statistics structure are handled by other threads; for example
when sayersListener() accepts a new connection from a sayer the member stats_sayersNum is increased
by one by sayersListener().
The only members that cannot be changed by the other threads and *must* be updated every some time unit
are stats_averageTwitsIncomingRate and stats_averageTwitsOutcomingRate. The time unit is obtained
from config.h (STATS_UPDATE_NSEC). The statisticsUpdater() function updates those two fields every
STATS_UPDATE_NSEC seconds.
statisticsUpdater () runs on its own thread that is responsible for updating the statistics member of the serverinfo structure that is passed as parameter . Most of the fields in the statistics structure are handled by other threads ; for example when sayersListener () accepts a new connection from a sayer the member stats_sayersNum is increased by one by sayersListener () . The only members that cannot be changed by the other threads and * must * be updated every some time unit are stats_averageTwitsIncomingRate and stats_averageTwitsOutcomingRate . The time unit is obtained from config . h ( STATS_UPDATE_NSEC ) . The statisticsUpdater () function updates those two fields every STATS_UPDATE_NSEC seconds .
void *statisticsUpdater( void *arg ){
	struct serverinfo *si = ( struct serverinfo * )arg;
	float averageTwitsIncomingRate = 0.0;
	float averageTwitsOutcomingRate = 0.0;
	assert( si != NULL );
	signal_prepared_status( si, 1 );
	while ( 1 ){
		sleep( STATS_UPDATE_NSEC );
		acquire_statistics( si );
		averageTwitsIncomingRate = si->si_stats.stats_averageTwitsIncomingRate = 
			( averageTwitsIncomingRate + si->si_stats.stats_arrivedTwitsNum ) / 2;
		averageTwitsOutcomingRate = si->si_stats.stats_averageTwitsOutcomingRate = 
			( averageTwitsOutcomingRate + si->si_stats.stats_deliveredTwitsNum ) / 2;
		release_statistics( si );
	}
	pthread_exit( NULL );
}
void * statisticsUpdater ( void * arg ) { struct serverinfo * si = ( struct serverinfo * ) arg ; float averageTwitsIncomingRate = 0.0 ; float averageTwitsOutcomingRate = 0.0 ; assert ( si != NULL ) ; signal_prepared_status ( si , 1 ) ; while ( 1 ) { sleep ( STATS_UPDATE_NSEC ) ; acquire_statistics ( si ) ; averageTwitsIncomingRate = si -> si_stats . stats_averageTwitsIncomingRate = ( averageTwitsIncomingRate + si -> si_stats . stats_arrivedTwitsNum ) / 2 ; averageTwitsOutcomingRate = si -> si_stats . stats_averageTwitsOutcomingRate = ( averageTwitsOutcomingRate + si -> si_stats . stats_deliveredTwitsNum ) / 2 ; release_statistics ( si ) ; } pthread_exit ( NULL ) ; }
statisticsUpdater() runs on its own thread that is responsible for updating the statistics member
 of the serverinfo structure that is passed as parameter.
statisticsUpdater () runs on its own thread that is responsible for updating the statistics member of the serverinfo structure that is passed as parameter .
// At first inform that preparation is over and successfull. // Every STATS_UPDATE_NSEC seconds  // Update the statistics structure