Пример #1
0
static jlog_line *
jlog_asynch_pop(jlog_asynch_ctx *actx, jlog_line **iter) {
  jlog_line *h = NULL, *rev = NULL;

  if(*iter) { /* we have more on the previous list */
    h = *iter;
    *iter = h->next;
    return h;
  }

  while(1) {
    h = (void *)(volatile void *)actx->head;
    if(noit_atomic_casptr((volatile void **)&actx->head, NULL, h) == h) break;
    /* TODO: load-load */
  }
  while(h) {
    /* which unshifted things into the queue -- it's backwards, reverse it */
    jlog_line *tmp = h;
    h = h->next;
    tmp->next = rev;
    rev = tmp;
  }
  if(rev) *iter = rev->next;
  else *iter = NULL;
  return rev;
}
Пример #2
0
void
jlog_asynch_push(jlog_asynch_ctx *actx, jlog_line *n) {
  while(1) {
    n->next = (void *)(volatile void *)actx->head;
    if(noit_atomic_casptr((volatile void **)&actx->head, n, n->next) == n->next) return;
    /* TODO: load-load */
  }
}
Пример #3
0
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(noit_atomic_casptr(vonlookers,
                           nnode, nnode->next) != (void *)nnode->next)
    nnode->next = onlookers;
}