library/src/utility/BP-GenericFastWeightedBalancer.cc
BP_ERROR_T BP_BalancerIncWeightEntryAtIndex(P_BP_WEIGHTED_BALANCER balancer , size_t index)
{

	// ensure we have a balancer
	if(!balancer)
		return ERR_FAILURE;

	// ensure our update index isn't greater than the index count
	if(index >= balancer->entry_n)
		return ERR_FAILURE;

	// never process overweight entries, but mark them as dropped
	if(balancer->entries[index].overweight)
	{
		balancer->total_hits_dropped_by_this_balancer++;
		return ERR_FAILURE;
	}

	// increment current hits
	balancer->entries[index].current_hits++;

	// increment the total hit count
	balancer->total_hits_processed_by_this_balancer++;

	// set the update flag
	balancer->requires_update=1;

	// return indicating success
	return ERR_SUCCESS;

}
// increment an index in the entry table, sets the update flag to true
increment an index in the entry table, sets the update flag to true
increment an index in the entry table sets the update flag to true
BP_ERROR_T BP_BalancerIncWeightEntryAtIndex(P_BP_WEIGHTED_BALANCER balancer , size_t index)
{
	if(!balancer)
		return ERR_FAILURE;
	if(index >= balancer->entry_n)
		return ERR_FAILURE;
	if(balancer->entries[index].overweight)
	{
		balancer->total_hits_dropped_by_this_balancer++;
		return ERR_FAILURE;
	}
	balancer->entries[index].current_hits++;
	balancer->total_hits_processed_by_this_balancer++;
	balancer->requires_update=1;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_BalancerIncWeightEntryAtIndex ( P_BP_WEIGHTED_BALANCER balancer , size_t index ) { if ( ! balancer ) return ERR_FAILURE ; if ( index >= balancer -> entry_n ) return ERR_FAILURE ; if ( balancer -> entries [ index ] . overweight ) { balancer -> total_hits_dropped_by_this_balancer ++ ; return ERR_FAILURE ; } balancer -> entries [ index ] . current_hits ++ ; balancer -> total_hits_processed_by_this_balancer ++ ; balancer -> requires_update = 1 ; return ERR_SUCCESS ; }
increment an index in the entry table, sets the update flag to true
increment an index in the entry table sets the update flag to true
// ensure we have a balancer // ensure our update index isn't greater than the index count // never process overweight entries, but mark them as dropped // increment current hits // increment the total hit count // set the update flag // return indicating success