2 #include "libbenchmark_datastructure_freelist_internal.h"
8 /****************************************************************************/
9 void libbenchmark_datastructure_freelist_pthread_spinlock_process_private_init( struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_state *fs, void *user_state )
11 LFDS710_PAL_ASSERT( fs != NULL );
12 LFDS710_PAL_ASSERT( user_state == NULL );
15 fs->user_state = user_state;
17 LIBBENCHMARK_PAL_LOCK_PTHREAD_SPINLOCK_PROCESS_PRIVATE_CREATE( fs->lock );
19 LFDS710_MISC_BARRIER_STORE;
21 lfds710_misc_force_store();
30 /****************************************************************************/
31 void libbenchmark_datastructure_freelist_pthread_spinlock_process_private_cleanup( struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_state *fs, void (*element_pop_callback)(struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_state *fs, struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_element *fe, void *user_state) )
33 struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_element
37 LFDS710_PAL_ASSERT( fs != NULL );
38 // TRD : element_pop_callback can be NULL
40 LFDS710_MISC_BARRIER_LOAD;
42 if( element_pop_callback != NULL )
51 element_pop_callback( fs, fe_temp, (void *) fs->user_state );
55 LIBBENCHMARK_PAL_LOCK_PTHREAD_SPINLOCK_PROCESS_PRIVATE_DESTROY( fs->lock );
64 /****************************************************************************/
65 void libbenchmark_datastructure_freelist_pthread_spinlock_process_private_push( struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_state *fs, struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_element *fe )
67 LFDS710_PAL_ASSERT( fs != NULL );
68 LFDS710_PAL_ASSERT( fe != NULL );
70 LIBBENCHMARK_PAL_LOCK_PTHREAD_SPINLOCK_PROCESS_PRIVATE_GET( fs->lock );
75 LIBBENCHMARK_PAL_LOCK_PTHREAD_SPINLOCK_PROCESS_PRIVATE_RELEASE( fs->lock );
84 /****************************************************************************/
85 #pragma warning( disable : 4100 )
87 int libbenchmark_datastructure_freelist_pthread_spinlock_process_private_pop( struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_state *fs, struct libbenchmark_datastructure_freelist_pthread_spinlock_process_private_element **fe )
92 LFDS710_PAL_ASSERT( fs != NULL );
93 LFDS710_PAL_ASSERT( fe != NULL );
95 LIBBENCHMARK_PAL_LOCK_PTHREAD_SPINLOCK_PROCESS_PRIVATE_GET( fs->lock );
100 fs->top = fs->top->next;
104 LIBBENCHMARK_PAL_LOCK_PTHREAD_SPINLOCK_PROCESS_PRIVATE_RELEASE( fs->lock );
109 #pragma warning( default : 4100 )