The Time Functions


Detailed Description

These functions deal with converting to and from the csp::Time type.

See also:
csp::Time

csp::RelTimeoutGuard

csp::TimeoutGuard


Classes

class  csp::RelTimeoutGuard
 An ALT relative timeout guard, for use in an Alternative. More...
struct  csp::Time
 C++CSP2 uses this typedef to represent times for the purposes of timeouts and waits. More...
class  csp::TimeoutGuard
 An ALT absolute timeout guard, for use in an Alternative. More...

Functions

Time csp::CurrentTime ()
 Gets the current time.
void csp::CurrentTime (Time *const val)
 Gets the current time.
csp::sign32 csp::GetMilliSeconds (const Time &val)
 Gets the number of milliseconds (truncated) in the specified time.
double csp::GetSeconds (const Time *val)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Included for compatibility with C++CSP v1.x.
double csp::GetSeconds (const Time &val)
 Gets the number of seconds from the specified Time.
Time csp::MicroSeconds (const long micros)
 Puts the specified integer amount of microseconds into a Time structure.
void csp::MicroSeconds (const long micros, Time *const val)
 Puts the specified integer amount of microseconds into a Time structure.
Time csp::MilliSeconds (const long millis)
 Puts the specified integer amount of milliseconds into a Time structure.
void csp::MilliSeconds (const long millis, Time *const val)
 Puts the specified integer amount of milliseconds into a Time structure.
Time csp::Seconds (const double secs)
 Puts the specified floating-point amount of seconds into a Time structure.
void csp::Seconds (const double secs, Time *const val)
 Puts the specified floating-point amount of seconds into a Time structure.
void csp::SleepFor (const Time &timeToSleepFor)
 Makes the current process sleep for the specified amount of time.
void csp::SleepUntil (const Time &timeToSleepUntil)
 Makes the current process sleep for the specified amount of time.


Function Documentation

void csp::MicroSeconds ( const long  micros,
Time *const   val 
)

Puts the specified integer amount of microseconds into a Time structure.

Parameters:
micros The (integer) amount of microseconds (millionths of a second)
val The Time structure to put the time into

void csp::MilliSeconds ( const long  millis,
Time *const   val 
)

Puts the specified integer amount of milliseconds into a Time structure.

Parameters:
millis The (integer) amount of milliseconds (thousandths of a second)
val The Time structure to put the time into

void csp::Seconds ( const double  secs,
Time *const   val 
)

Puts the specified floating-point amount of seconds into a Time structure.

Note that this function takes a double, not an int like the other two functions. This number may be truncated/rounded during the course of the conversion into the Time structure.

Parameters:
secs The (floating-point) amount of seconds
val The Time structure to put the time into

Time csp::MicroSeconds ( const long  micros  )  [inline]

Puts the specified integer amount of microseconds into a Time structure.

Parameters:
micros The (integer) amount of microseconds (millionths of a second)
Returns:
The Time structure with the value in it

Time csp::MilliSeconds ( const long  millis  )  [inline]

Puts the specified integer amount of milliseconds into a Time structure.

Parameters:
millis The (integer) amount of milliseconds (thousandths of a second)
Returns:
The Time structure with the value in it

Time csp::Seconds ( const double  secs  )  [inline]

Puts the specified floating-point amount of seconds into a Time structure.

Note that this function takes a double, not an int like the other two functions. This number may be truncated/rounded during the course of the conversion into the Time structure.

Parameters:
secs The (floating-point) amount of seconds
Returns:
The time structure with the value in it

double csp::GetSeconds ( const Time &  val  ) 

Gets the number of seconds from the specified Time.

The precision will be based upon the precision of the underlying mechanism as well as the precision of the double type

Parameters:
val A pointer to the Time

double csp::GetSeconds ( const Time *  val  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Included for compatibility with C++CSP v1.x.

sign32 csp::GetMilliSeconds ( const Time &  val  ) 

Gets the number of milliseconds (truncated) in the specified time.

Parameters:
val A pointer to the Time

void csp::CurrentTime ( Time *const   val  ) 

Gets the current time.

The value of this time may vary from operating system to operating system. It may be the number of seconds since the 1970 epoch, or it may be the number of seconds since the machine booted up. No guarantees are offered as to the relevance of its absolute value.

Instead, it should be used only for relative purposes - working out a specified time before or since now.

Parameters:
val The place to put the current time

Time csp::CurrentTime (  )  [inline]

Gets the current time.

The value of this time may vary from operating system to operating system. It may be the number of seconds since the 1970 epoch, or it may be the number of seconds since the machine booted up. No guarantees are offered as to the relevance of its absolute value.

Instead, it should be used only for relative purposes - working out a specified time before or since now.

Returns:
The current time

void csp::SleepFor ( const Time &  timeToSleepFor  ) 

Makes the current process sleep for the specified amount of time.

There are no guarantees as to exactly how early the process will be scheduled again. In the mean-time, other processes in the thread may run (or other threads in the system) so this cannot be known exactly. However, the call will never return early - timeToSleepFor will always have elapsed.

Postcondition:
CurrentTime() >= (timeToSleepFor + StartT), where StartT is the result of CurrentTime() when the function is called

void csp::SleepUntil ( const Time &  timeToSleepUntil  ) 

Makes the current process sleep for the specified amount of time.

There are no guarantees as to exactly how early the process will be scheduled again. In the mean-time, other processes in the thread may run (or other threads in the system) so this cannot be known exactly. However, the call will never return early - it will always be timeToSleepUntil or later.

Postcondition:
CurrentTime() >= timeToSleepUntil


Generated on Mon Aug 20 12:24:28 2007 for C++CSP2 by  doxygen 1.4.7