Sha256: 018d26b7fc325b03b8dc7a4b314c14dc9f77a9f6792eafedaa2e109f956f772b

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

#ifndef BACKEND_IO_URING_CONTEXT_H
#define BACKEND_IO_URING_CONTEXT_H

#include "ruby.h"

enum op_type {
  OP_NONE,
  OP_READ,
  OP_WRITEV,
  OP_WRITE,
  OP_RECV,
  OP_SEND,
  OP_SPLICE,
  OP_TIMEOUT,
  OP_POLL,
  OP_ACCEPT,
  OP_CONNECT,
  OP_CHAIN
};

typedef struct op_context {
  struct op_context *prev;
  struct op_context *next;
  enum op_type      type: 16;
  unsigned int      ref_count : 16;       
  int               id;
  int               result;
  VALUE             fiber;
  VALUE             resume_value;
} op_context_t;

typedef struct op_context_store {
  int           last_id;
  op_context_t  *available;
  op_context_t  *taken;
  int           available_count;
  int           taken_count;
} op_context_store_t;

const char *op_type_to_str(enum op_type type);

void context_store_initialize(op_context_store_t *store);
op_context_t *context_store_acquire(op_context_store_t *store, enum op_type type);
int context_store_release(op_context_store_t *store, op_context_t *ctx);
void context_store_free(op_context_store_t *store);

inline unsigned int OP_CONTEXT_RELEASE(op_context_store_t *store, op_context_t *ctx) {
  int completed = !ctx->ref_count;
  if (ctx->ref_count)
    ctx->ref_count -= 1;
  else
    context_store_release(store, ctx);
  return completed;
}

#endif /* BACKEND_IO_URING_CONTEXT_H */

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
polyphony-0.65 ext/polyphony/backend_io_uring_context.h
polyphony-0.64 ext/polyphony/backend_io_uring_context.h
polyphony-0.63 ext/polyphony/backend_io_uring_context.h
polyphony-0.62 ext/polyphony/backend_io_uring_context.h
polyphony-0.61 ext/polyphony/backend_io_uring_context.h
polyphony-0.60 ext/polyphony/backend_io_uring_context.h