Skip to content

lock-free LIFO stack by C native built it, easy built cross platform(no extra dependencies needed) , guarantee thread safety memory management ever!

License

Notifications You must be signed in to change notification settings

Taymindis/lfstack

Repository files navigation

lfstack Build Status

lock-free LIFO stack by C native built it, easy built cross platform(no extra dependencies needed) , guarantee thread safety memory management ever!

All Platform tests

GCC/CLANG | Build Status

VS x64/x86 | Build status

API

externintlfstack_init(lfstack_t*lfstack); externintlfstack_push(lfstack_t*lfstack, void*value); externvoid*lfstack_pop(lfstack_t*lfstack); externvoid*lfstack_single_pop(lfstack_t*lfstack); externvoidlfstack_destroy(lfstack_t*lfstack); externsize_tlfstack_size(lfstack_t*lfstack); externvoidlfstack_sleep(unsigned intmilisec);

Example

int*int_data; lfstack_tmystack; if (lfstack_init(&mystack) ==-1) return-1; /** Wrap This scope in other threads **/int_data= (int*) malloc(sizeof(int)); assert(int_data!=NULL); *int_data=i++; /*PUSH*/while (lfstack_push(&mystack, int_data) ==-1){printf("ENQ Full ?\n")} /** Wrap This scope in other threads **//*POP*/while ( (int_data=lfstack_pop(&mystack)) ==NULL){printf("POP EMPTY ..\n")} // printf("%d\n", *(int*) int_data );free(int_data); /** End **/lfstack_destroy(&mystack);

If you are using single thread POP. Please use lfstack_single_pop to get better performance

Build and Installation

For linux OS, you may use cmake build, for other platforms, please kindly include the source code and header file into the project, e.g. VS2017, DEV-C++, Xcode

mkdir build cd build cmake .. make ./lfstack-example valgrind --tool=memcheck --leak-check=full ./lfstack-example sudo make install 

continuously Test

For continuously test until N number, if you having any issue while testing, please kindly raise an issue

./keep-testing.sh 

Uninstallation

cd build sudo make uninstall 

You may also like lock free queue FIFO

lfqueue

About

lock-free LIFO stack by C native built it, easy built cross platform(no extra dependencies needed) , guarantee thread safety memory management ever!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •