示例#1
0
/**
 * Sends a message to a thread.
 */
static void send_msg(uint32_t to, sched_msg_t msg, intptr_t arg)
{
  pony_msgi_t* m = (pony_msgi_t*)pony_alloc_msg(
    POOL_INDEX(sizeof(pony_msgi_t)), msg);

  m->i = arg;
  ponyint_messageq_push(&scheduler[to].mq, &m->msg);
}
示例#2
0
文件: iocp.c 项目: DevL/ponyc
static void send_request(asio_event_t* ev, int req)
{
  asio_backend_t* b = asio_get_backend();

  asio_msg_t* msg = (asio_msg_t*)pony_alloc_msg(
    POOL_INDEX(sizeof(asio_msg_t)), 0);
  msg->event = ev;
  msg->flags = req;
  messageq_push(&b->q, (pony_msg_t*)msg);

  SetEvent(b->wakeup);
}
示例#3
0
void ponyint_messageq_init(messageq_t* q)
{
  pony_msg_t* stub = POOL_ALLOC(pony_msg_t);
  stub->size = POOL_INDEX(sizeof(pony_msg_t));
  stub->next = NULL;

  q->head = (pony_msg_t*)((uintptr_t)stub | 1);
  q->tail = stub;

#ifndef NDEBUG
  messageq_size_debug(q);
#endif
}
示例#4
0
void ponyint_messageq_init(messageq_t* q)
{
  pony_msg_t* stub = POOL_ALLOC(pony_msg_t);
  stub->index = POOL_INDEX(sizeof(pony_msg_t));
  atomic_store_explicit(&stub->next, NULL, memory_order_relaxed);

  atomic_store_explicit(&q->head, (pony_msg_t*)((uintptr_t)stub | 1),
    memory_order_relaxed);
  q->tail = stub;

#ifndef NDEBUG
  messageq_size_debug(q);
#endif
}
示例#5
0
文件: event.c 项目: DevL/ponyc
void asio_event_send(asio_event_t* ev, uint32_t flags, uint32_t arg)
{
  asio_msg_t* m = (asio_msg_t*)pony_alloc_msg(POOL_INDEX(sizeof(asio_msg_t)),
    ev->msg_id);
  m->event = ev;
  m->flags = flags;
  m->arg = arg;

#ifdef PLATFORM_IS_WINDOWS
  // On Windows, this can be called from an IOCP callback thread, which may
  // not have a pony_ctx() associated with it yet.
  pony_register_thread();
#endif

  pony_sendv(pony_ctx(), ev->owner, &m->msg);
}
示例#6
0
文件: epoll.c 项目: ponylang/ponyc
static void send_request(asio_event_t* ev, int req)
{
  asio_backend_t* b = ponyint_asio_get_backend();
  pony_assert(b != NULL);

  asio_msg_t* msg = (asio_msg_t*)pony_alloc_msg(
    POOL_INDEX(sizeof(asio_msg_t)), 0);
  msg->event = ev;
  msg->flags = req;
  ponyint_thread_messageq_push(&b->q, (pony_msg_t*)msg, (pony_msg_t*)msg
#ifdef USE_DYNAMIC_TRACE
    , SPECIAL_THREADID_EPOLL, SPECIAL_THREADID_EPOLL
#endif
    );

  eventfd_write(b->wakeup, 1);
}