- Minor fix: Set correct names in comments at top of file - New FileCore Class: - Writing data to output file - BufferCore: - Check for "EAGAIN" on write and retry write - FunctionCore: - Add new Output method that references LocalIO directly - SelectableCore: - New method SetAutomanage to specify auto re-open parameters - Re-open timer implemented to slow re-open events - Only call ProcessBuffer() if data received on socket - Force processing input data when no input marker set - Use new Output method to simplify code - Bug fix: Read correctly from buffer on multiple reads/writes on FD - Check for "EAGAIN" on write to FD and retry write
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
/*
|
|
* TimingCore.cpp
|
|
*
|
|
* Created on: 13 May 2016
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
// redA Librarie
|
|
#include "TimingCore.h"
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Set time
|
|
void SetInterval( timeval * Time, long MilliSeconds )
|
|
{
|
|
// milli-seconds -> seconds
|
|
Time->tv_sec = MilliSeconds / 1000;
|
|
// milli-seconds -> micro-seconds
|
|
Time->tv_usec = (MilliSeconds % 1000) * 1000;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Populated start time
|
|
void SetStartTime( timeval * StartTime )
|
|
{
|
|
// Get current time
|
|
gettimeofday( StartTime, NULL );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Clear start time
|
|
void ClearStartTime( timeval * StartTime )
|
|
{
|
|
// Get current time
|
|
StartTime->tv_sec = 0;
|
|
StartTime->tv_usec = 0;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Calculate TimePassed from Start Time (in milli-seconds)
|
|
long TimePassed( timeval StartTime )
|
|
{
|
|
timeval CurrTime;
|
|
long Duration;
|
|
|
|
// Get current time
|
|
gettimeofday( &CurrTime, NULL );
|
|
|
|
// Get time passed in milli-seconds
|
|
Duration = (CurrTime.tv_sec - StartTime.tv_sec) * 1000 +
|
|
(CurrTime.tv_usec - StartTime.tv_usec) / 1000;
|
|
|
|
return Duration;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
bool Timeout( timeval StartTime, long MilliSeconds )
|
|
{
|
|
return ((TimePassed(StartTime) > MilliSeconds)? true : false);
|
|
}
|
|
//---------------------------------------------------------------------------
|