Example #1
0
int CSocketBackend::Read(void *buffer, unsigned int len, int& error)
{
	wxLongLong max = GetAvailableBytes(CRateLimiter::inbound);
	if (max == 0)
	{
		Wait(CRateLimiter::inbound);
		error = EAGAIN;
		return -1;
	}
	else if (max > 0 && max < len)
		len = max.GetLo();

	int read = m_pSocket->Read(buffer, len, error);

	if (read > 0 && max != -1)
		UpdateUsage(CRateLimiter::inbound, read);

	return read;
}
Example #2
0
    void AbstractBednet::Update( float dt )
    {
        if( Expired() ) return;

        if( !BaseIntervention::UpdateIndividualsInterventionStatus() ) return;

        UpdateUsage( dt );
        UpdateBlockingAndKilling( dt );

        if( IsUsingBednet() )
        {
            UseBednet();
        }

        if( CheckExpiration( dt ) )
        {
            SetExpired( true );
        }
    }
Example #3
0
int CSocketBackend::Write(const void *buffer, unsigned int len, int& error)
{
	wxLongLong max = GetAvailableBytes(CRateLimiter::outbound);
	if (max == 0)
	{
		Wait(CRateLimiter::outbound);
		error = EAGAIN;
		return -1;
	}
	else if (max > 0 && max < len)
		len = max.GetLo();

	int written = m_pSocket->Write(buffer, len, error);
	
	if (written > 0 && max != -1)
		UpdateUsage(CRateLimiter::outbound, written);

	return written;
}