int pony_stop() { ponyint_sched_stop(); ponyint_os_sockets_final(); return _atomic_load(&exit_code); }
int pony_stop() { scheduler_stop(); os_socket_shutdown(); return _atomic_load(&exit_code); }
int pony_stop() { scheduler_stop(); os_socket_shutdown(); return _atomic_load(&exit_code, __ATOMIC_ACQUIRE); }
void* ponyint_mpmcq_pop(mpmcq_t* q) { mpmcq_dwcas_t cmp, xchg; mpmcq_node_t* next; cmp.aba = q->tail.aba; cmp.node = q->tail.node; do { // Get the next node rather than the tail. The tail is either a stub or has // already been consumed. next = _atomic_load(&cmp.node->next); // Bailout if we have no next node. if(next == NULL) return NULL; // Make the next node the tail, incrementing the aba counter. If this // fails, cmp becomes the new tail and we retry the loop. xchg.aba = cmp.aba + 1; xchg.node = next; } while(!_atomic_dwcas(&q->tail.dw, &cmp.dw, xchg.dw)); // We'll return the data pointer from the next node. void* data = _atomic_load(&next->data); // Since we will be freeing the old tail, we need to be sure no other // consumer is still reading the old tail. To do this, we set the data // pointer of our new tail to NULL, and we wait until the data pointer of // the old tail is NULL. _atomic_store(&next->data, NULL); while(_atomic_load(&cmp.node->data) != NULL) ponyint_cpu_relax(); // Free the old tail. The new tail is the next node. POOL_FREE(mpmcq_node_t, cmp.node); return data; }
int pony_start(bool library) { if(!ponyint_os_sockets_init()) return -1; if(!ponyint_sched_start(library)) return -1; if(library) return 0; return _atomic_load(&exit_code); }
pony_msg_t* ponyint_messageq_pop(messageq_t* q) { pony_msg_t* tail = q->tail; pony_msg_t* next = _atomic_load(&tail->next); if(next != NULL) { q->tail = next; ponyint_pool_free(tail->size, tail); } return next; }
int pony_start(bool library) { if(!os_socket_init()) return -1; if(!scheduler_start(library)) return -1; if(library) return 0; return _atomic_load(&exit_code); }
bool ponyint_messageq_markempty(messageq_t* q) { pony_msg_t* tail = q->tail; pony_msg_t* head = _atomic_load(&q->head); if(((uintptr_t)head & 1) != 0) return true; if(head != tail) return false; head = (pony_msg_t*)((uintptr_t)head | 1); return _atomic_cas(&q->head, &tail, head); }