void stratcon_datastore_register_onlooker(void (*f)(stratcon_datastore_op_t, struct sockaddr *, const char *, void *)) { struct datastore_onlooker_list *nnode; volatile void **vonlookers = (void *)&onlookers; nnode = calloc(1, sizeof(*nnode)); nnode->dispatch = f; nnode->next = onlookers; while(mtev_atomic_casptr(vonlookers, nnode, nnode->next) != (void *)nnode->next) nnode->next = onlookers; }
static int get_my_lane() { if(my_lane.fifo == NULL) { int new_thread; my_lane.fifo = calloc(1, sizeof(ck_fifo_spsc_t)); ck_fifo_spsc_init(my_lane.fifo, malloc(sizeof(ck_fifo_spsc_entry_t))); for(new_thread=0;new_thread<nthreads;new_thread++) { if(mtev_atomic_casptr(&thread_queues[new_thread], my_lane.fifo, NULL) == NULL) break; } mtevAssert(new_thread<nthreads); my_lane.id = new_thread; mtevL(mtev_debug, "Assigning thread(%p) to %d\n", (void*)(uintptr_t)pthread_self(), my_lane.id); } return my_lane.id; }