Skip to content

nitzanms/acync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Acync

C multithreading code inspired by C++'s std::async. Call functions on a separate thread, then get the result. Currently only platforms with pthreads are supported.

Acync is currently very much under development.

Using Acync

  • Change test.def to create new functions that can be called in another thread. Functions must not return void.
  • Implement the functions in fun_macros.h.
  • Use async__caller() to call the function. The return value type is ASYNC_RES(function_name).
  • Use get__async_result to wait until the result is available. If an error happened the return value is undefined and an error code will be passed in the second parameter, if it is not NULL.
  • Use 'make' to then build the code. You can use the prog_prepro.c file to see what was generated.
  • ASYNC_RES is a pointer. It can be passed around.

Caveats

  • The ASYNC_RES is allocated and released dynamically, in async_caller and in get_async_result accordingly.
  • get__async_result must be called on each ASYNC_RES exactly once. Calling it again is undefined. Not calling it will result in resource leaks.

About

C multithreading code inspired by C++'s std::async. Call functions on a separate thread, then get the result.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors