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

Threads





The threads module header is lapin/threads.h The LibLapin currently does not support threading on Window. Functions still works, but they are single threaded.

I hope to change this on the next version (1.13).
typedef struct s_bunny_threadpool
{
     const void * const _private;
     size_t nbr_threads;

} t‌_‌b‌u‌n‌n‌y‌_‌t‌h‌r‌e‌a‌d‌p‌o‌o‌l;

Description

     This structure is an abstract type made to represent created threads.

Attributes

  • const void * const _private:
         Private attribute that must not be modified or a crash may happen.
  • size_t nbr_threads:
         The amount of threads that this threadpool represents.


INDEX


Description

     Create size threads and generate a structure that represent them.

The returned threadpool must be destroyed with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌t‌h‌r‌e‌a‌d‌p‌o‌o‌l.

Parameters

  • size_t size:
         The amount of threads you want to create.

Return value

  • On success, the function returns the threadpool.
  • On failure, it returns NULL.

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 "thread" label.




INDEX


Description

     Delete the sent threadpool.

Parameters




INDEX

typedef void (*t‌_‌b‌u‌n‌n‌y‌_‌f‌u‌n‌c‌t‌i‌o‌n)( void *data, void *add_ptr );

Description

     This function pointer is used by b‌u‌n‌n‌y‌_‌t‌h‌r‌e‌a‌d‌_‌f‌o‌r‌e‌a‌c‌h as target function for threaded collection computation.

Parameters




INDEX


Description

     Push a single work in the threadpool.

Parameters


Return value

  • On success, the function returns true.
  • On failure, it returns false.

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 "thread" label.




INDEX


Description

     Split an array computation into threads to speed them. The main thread does not work with the other one, it goes on directly. You may call b‌u‌n‌n‌y‌_‌t‌h‌r‌e‌a‌d‌_‌w‌a‌i‌t‌_‌c‌o‌m‌p‌l‌e‌t‌i‌o‌n if you need to make it wait for the others to end their work.

Parameters


Return value

  • On success, the function returns true.
  • On failure, it returns false.

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 "thread" label.




INDEX


Description

     Wait until all works are complete and there is no more awaiting work in the threadpool queue.

Parameters




INDEX


Description

     Create a threadpool integrated to the bunny loop with the sent amount of thread.

Parameters

  • size_t nbr_thread:
         The amount of threads inside the bunny loop thread pool. You can send 0 to delete the threadpool.
    If a threadpool was already present, it may be freed before a new one is created if it contains a different amount of threads.

Return value

  • On success, the function returns true.
  • On failure, it returns false.



INDEX


Description

     This function push a computation request inside the bunny loop thread pool.

Parameters


Return value

  • On success, the function returns true.
  • On failure, it returns false.



INDEX


Description

     This function push several computation request inside the bunny loop thread pool. As many as len.

Parameters


Return value

  • On success, the function returns true.
  • On failure, it returns false.



INDEX