Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Asynclock





The asynclock module header is lapin/asynclock.h

Description

     A timestamp in nanoseconds.


INDEX


Description

     Return the system time.

Return value

The system time under the form of a timestamp with nanosecond precision.




INDEX

unsigned long long b‌u‌n‌n‌y‌_‌u‌s‌l‌e‌e‌p( unsigned long long delay );

Description

     Wait until the sent delay expire. In microseconds.

Return value

The difference between the effectively wait time and the one that was requested. This may happen if a signal interrupt the program. In most case, 0 is returned.




INDEX


Description

     Wait until the sent delay expire. In nanoseconds.

Return value

The difference between the effectively wait time and the one that was requested. This may happen if a signal interrupt the program. In most case, 0 is returned.




INDEX


Description

     Return the difference between both time.

Return value

The difference between both time.




INDEX

typedef enum e_bunny_call_order
{
     BCO_BEFORE_LOOP_MAIN_FUNCTION,      BCO_AFTER_LOOP_MAIN_FUNCTION
} t‌_‌b‌u‌n‌n‌y‌_‌a‌l‌i‌g‌n;

Description

     This enumeration helps you to configure if you want to trigger traps before or after the function set as the main one with b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌l‌o‌o‌p‌_‌m‌a‌i‌n‌_‌f‌u‌n‌c‌t‌i‌o‌n.



INDEX


Description

     This function will be called when its matching trap occurs. It will receive informations about the trap and also arbitrary value.

You can safely delete the sent trap with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌t‌r‌a‌p, it will not cause any trouble: it will only be marked for suppression and be deleted when it is possible.

Parameters




INDEX

typedef struct s_bunny_trap
{
     const char _private[3 * sizeof(void*)];
     const double start_time;
     const double duration;
     t‌_‌b‌u‌n‌n‌y‌_‌t‌r‌a‌p‌_‌f‌u‌n‌c‌t‌i‌o‌n function;
     void *additional_param;

} t‌_‌b‌u‌n‌n‌y‌_‌t‌r‌a‌p;

Description

     This structure is partially abstract. The only editable fields are the function called when the trap happen and the arbitrary data that is sent.

This structure represents a trap: an event that occurs under condition of pace.

Attributes




INDEX


Description

     Create a new trap and configure it.

You can remove the trap by deleting it with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌t‌r‌a‌p.

Parameters

  • t‌_‌b‌u‌n‌n‌y‌_‌t‌r‌a‌p‌_‌f‌u‌n‌c‌t‌i‌o‌n function:
         A function to call when the configured condition is fulfilled.
  • t‌_‌b‌u‌n‌n‌y‌_‌c‌a‌l‌l‌_‌o‌r‌d‌e‌r order:
         Configure if the function is called before or after the function set by b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌l‌o‌o‌p‌_‌m‌a‌i‌n‌_‌f‌u‌n‌c‌t‌i‌o‌n.
  • double start_time:
         The parameter start_time is in second when the trap can start to act, if it is positive.
         If start_time is negative or zero, then instead of waiting a specific time to happen, the trap will wait that any other trap before him made their business.
  • double duration:
         If start_time is positive, then the parameter act this way:
    • If duration is superior to 0, each loop if the current time is between start_time and tart_time + duration, the sent function is called.
    • If duration is 0 or really close, the function will be called a single time after start_time and then never called again.
    • If duration is negative, then the function will be called every -duration seconds if the curent time is greater than start_time.
         If $start_time is negative, it works the same way, except that there is no other start_time than where there is no more trap awaiting.
  • void *param:
         A parameter that will be sent as third parameter of function.

Return value


Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "asynclock" label.




INDEX


Description

     Delete the sent trap from the system. Actually, it does not delete it but mark it for deletion. The function b‌u‌n‌n‌y‌_‌a‌s‌y‌n‌c‌l‌o‌c‌k will delete it itself when browsing traps and seeing it is marked.

Parameters



INDEX


Description

     Browse traps are call associated functions if matching conditions are fulfilled.

Parameters


Return value

Returns how my traps are still registered.




INDEX


Description

     Set the bunny clock (the inside time counter which is synchronised with the event loop) to the current real time and return it.

Return value

Return the current real time in seconds.




INDEX


Description

     Return the bunny clock (the inside time counter which is synchronised with the event loop).

Return value

Return the current bunny clock, in seconds.




INDEX