Skip to content

A lightweight cross platform library for thread management

License

Notifications You must be signed in to change notification settings

pierreguillot/thread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THD

A lightweight cross platform library for thread management

Build Status
Build Status
Coverage Status

Platforms

  • Linux
  • MacOS
  • Windows

Installation

mkdir build
cd build
cmake ..  
cmake --build .
test (optional)

Documentation

  • Thread

  • Detaches a thread:
    `int thd_thread_detach(thd_thread* thread, thd_thread_method method, void* data)``

  • Joins a thread:
    int thd_thread_join(thd_thread* thread);

  • Mutex

  • Initializes a mutex:
    int thd_mutex_init(thd_mutex* mutex);

  • Locks a mutex:
    int thd_mutex_lock(thd_mutex* mutex);

  • Tries to lock a mutex:
    int thd_mutex_trylock(thd_mutex* mutex);

  • Unlocks a mutex:
    int thd_mutex_unlock(thd_mutex* mutex);

  • Destroy a mutex:
    int thd_mutex_destroy(thd_mutex* mutex);

  • Condition

  • Initializes a condition:
    int thd_condition_init(thd_condition* cond);

  • Restarts one of the threads that are waiting on the condition:
    int thd_condition_signal(thd_condition* cond);

  • Unlocks the mutex and waits for the condition to be signalled:
    int thd_condition_wait(thd_condition* cond, thd_mutex* mutex);

  • Destroy a condition:
    int thd_condition_destroy(thd_condition* cond);

Example

Note: On Windows, you need to add pthreadwin folder in the header search path to use the pthread interface.

About

A lightweight cross platform library for thread management

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published