Exemple #1
0
void pony_serialise(pony_ctx_t* ctx, void* p, void* out)
{
  // This can raise an error.
  assert(ctx->stack == NULL);
  ctx->trace_object = ponyint_serialise_object;
  ctx->trace_actor = ponyint_serialise_actor;
  ctx->serialise_size = 0;

  pony_traceunknown(ctx, p, PONY_TRACE_MUTABLE);
  ponyint_gc_handlestack(ctx);

  ponyint_array_t* r = (ponyint_array_t*)out;
  r->size = ctx->serialise_size;
  r->alloc = r->size;
  r->ptr = (char*)ponyint_pool_alloc_size(r->size);

  size_t i = HASHMAP_BEGIN;
  serialise_t* s;

  while((s = ponyint_serialise_next(&ctx->serialise, &i)) != NULL)
  {
    if(s->t != NULL)
      s->t->serialise(ctx, (void*)s->key, r->ptr, s->value, s->mutability);
  }

  serialise_cleanup(ctx);
}
Exemple #2
0
PONY_API void pony_asio_event_destroy(asio_event_t* ev)
{
  if((ev == NULL) || (ev->magic != ev) || (ev->flags != ASIO_DISPOSABLE))
  {
    pony_assert(0);
    return;
  }

  ev->flags = ASIO_DESTROYED;

  // When we let go of an event, we treat it as if we had received it back from
  // the asio thread.
  pony_ctx_t* ctx = pony_ctx();
  pony_gc_recv(ctx);
  pony_traceunknown(ctx, ev->owner, PONY_TRACE_OPAQUE);
  pony_recv_done(ctx);

  POOL_FREE(asio_event_t, ev);
}