NXTimeOutSchedule

Schedules a function to be executed at a specified time.

Library:LibC
Classification:NKS
Service:Timeout

Syntax

  #include <nks/time.h> 
   
  int NXTimeOutSchedule (
     NXTimeOut_t  *tout);
  

Parameters

tout

(IN) Points to an initialized NXTimeOut_t structure. You are responsible for allocating and initializing this structure. See NXTimeOut_t:

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Hex

Constant

Description

24

0x18

NX_EAGAIN

Insufficient resources

Remarks

On expiration of the timer, the specified function is executed.

IMPORTANT:No assumptions can be made about the thread or the thread context that executes the function. Specifically, the function cannot sleep or reference key-data pairs.

On successful completion of NXTimeOutSchedule, memory pointed to by the tout parameter is transferred to the system. Modifying the NXTimeOut_t structure after ownership has been transferred to the system can result in unpredictable behavior.

On successful return, the timeout structure pointer passed to the function can subsequently be used to cancel the timeout.

Ownership of a scheduled timeout can be reclaimed by an application by calling NXTimeOutCancel. If you allocated memory for the timeout structure, you are responsible to free the allocated memory when the following considerations are satisfied:

  • A single-shot timeout has completed execution or has been successfully canceled using the synchronous cancel operation of NXTimeOutCancel.

  • A periodic timeout has been successfully canceled using the synchronous cancel operation of NXTimeOutCancel.

  • The ownership of a timeout has transferred back to the application from a non-synchronous cancel operation. You are responsible for determining exactly when this occurs.

Race conditions between NXTimeOutSchedule and NXTimeOutCancel that involve the same timeout are not handled and can lead to unexpected results.

See Also