github.com/moontrade/nogc@v0.1.7/collections/tree/lock.h (about) 1 #ifndef moontrade_ordered_LOCK_H 2 #define moontrade_ordered_LOCK_H 3 4 #include <stdint.h> 5 #include <stdlib.h> 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 12 typedef struct moontrade_ordered_rwlock_t { 13 void (*lock)(size_t arg0, size_t arg1); 14 } moontrade_ordered_rwlock_t; 15 16 extern void moontrade_ordered_sleep(uint64_t nanos); 17 extern uint64_t moontrade_ordered_rwlock_size(); 18 extern void moontrade_ordered_rwlock_new(size_t arg0, size_t arg1); 19 extern void moontrade_ordered_rwlock_try_lock(size_t lock, size_t arg1); 20 extern void moontrade_ordered_rwlock_lock(size_t arg0, size_t arg1); 21 extern void moontrade_ordered_rwlock_unlock(size_t lock, size_t arg1); 22 extern void moontrade_ordered_rwlock_unlock_and_lock_shared(size_t lock, size_t arg1); 23 extern void moontrade_ordered_rwlock_try_lock_shared(size_t lock, size_t arg1); 24 extern void moontrade_ordered_rwlock_lock_shared(size_t lock, size_t arg1); 25 extern void moontrade_ordered_rwlock_unlock_shared(size_t lock, size_t arg1); 26 extern void moontrade_ordered_rwlock_destroy(size_t lock, size_t arg1); 27 28 typedef struct moontrade_ordered_rwticketlock_t moontrade_ordered_rwticketlock_t; 29 30 extern uint64_t moontrade_ordered_rwticketlock_size(); 31 extern void moontrade_ordered_rwticketlock_new(size_t arg0, size_t arg1); 32 extern void moontrade_ordered_rwticketlock_lock(size_t lock, size_t arg1); 33 extern void moontrade_ordered_rwticketlock_lock_aggressive(size_t lock, size_t arg1); 34 extern void moontrade_ordered_rwticketlock_lock_nice(size_t lock, size_t arg1); 35 extern void moontrade_ordered_rwticketlock_unlock(size_t lock, size_t arg1); 36 extern void moontrade_ordered_rwticketlock_unlock_and_lock_shared(size_t lock, size_t arg1); 37 extern void moontrade_ordered_rwticketlock_try_lock(size_t lock, size_t arg1); 38 extern void moontrade_ordered_rwticketlock_try_lock_shared(size_t lock, size_t arg1); 39 extern void moontrade_ordered_rwticketlock_lock_shared(size_t lock, size_t arg1); 40 extern void moontrade_ordered_rwticketlock_unlock_shared(size_t lock, size_t arg1); 41 extern void moontrade_ordered_rwticketlock_destroy(size_t lock, size_t arg1); 42 43 struct moontrade_ordered_lock_api { 44 int fair; 45 void (* lock)(void* lock); 46 void (* unlock)(void* lock); 47 void (* lock_shared)(void* lock); 48 void (* unlock_shared)(void* lock); 49 }; 50 extern const struct moontrade_ordered_lock_api moontrade_ordered_lock_unfair_api; 51 extern const struct moontrade_ordered_lock_api moontrade_ordered_lock_fair_api; 52 53 #ifdef __cplusplus 54 } 55 #endif 56 57 #endif //moontrade_ordered_LOCK_H