Chan is a generic, thread-safe, concurrent FIFO (Queue data structure) implementation similar to Go channles in C99. It supports buffered and unbuffered modes.
Note
The library itself (chan.c and chan.h) is implemented with ANSI C99 standard. But some examples use gnu99 standard for non-std functionalities.
Warning
This project is for learning purposes. Do NOT use this in production or your projects.
This library is written with pthread and it's a single chan.c file. To build the example program main.c:
makeThis will build an executable that uses chan.c and chan.h files. The test creates 4 producer threads that push integer
values to the channel with 4 consumer threads. Consumer threads pop integer values from channel and print them.
Read chan.h file. It's easy to understand :)