Sha256: 6aeff7f2d351ce48b772a3c6c25432bfa6caee9c354c93186b639f86134d5657

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 KB

Contents

#include "polyphony.h"
#include "runqueue.h"

inline void runqueue_initialize(runqueue_t *runqueue) {
  runqueue_ring_buffer_init(&runqueue->entries);
  runqueue->high_watermark = 0;
}

inline void runqueue_finalize(runqueue_t *runqueue) {
  runqueue_ring_buffer_free(&runqueue->entries);
}

inline void runqueue_mark(runqueue_t *runqueue) {
  runqueue_ring_buffer_mark(&runqueue->entries);
}

inline void runqueue_push(runqueue_t *runqueue, VALUE fiber, VALUE value, int reschedule) {
  if (reschedule) runqueue_ring_buffer_delete(&runqueue->entries, fiber);
  runqueue_ring_buffer_push(&runqueue->entries, fiber, value);
  if (runqueue->entries.count > runqueue->high_watermark)
    runqueue->high_watermark = runqueue->entries.count;
}

inline void runqueue_unshift(runqueue_t *runqueue, VALUE fiber, VALUE value, int reschedule) {
  if (reschedule) runqueue_ring_buffer_delete(&runqueue->entries, fiber);
  runqueue_ring_buffer_unshift(&runqueue->entries, fiber, value);
  if (runqueue->entries.count > runqueue->high_watermark)
    runqueue->high_watermark = runqueue->entries.count;
}

inline runqueue_entry runqueue_shift(runqueue_t *runqueue) {
  return runqueue_ring_buffer_shift(&runqueue->entries);
}

inline void runqueue_delete(runqueue_t *runqueue, VALUE fiber) {
  runqueue_ring_buffer_delete(&runqueue->entries, fiber);
}

inline int runqueue_index_of(runqueue_t *runqueue, VALUE fiber) {
  return runqueue_ring_buffer_index_of(&runqueue->entries, fiber);
}

inline void runqueue_clear(runqueue_t *runqueue) {
  runqueue_ring_buffer_clear(&runqueue->entries);
}

inline long runqueue_size(runqueue_t *runqueue) {
  return runqueue->entries.size;
}

inline long runqueue_len(runqueue_t *runqueue) {
  return runqueue->entries.count;
}

inline long runqueue_max_len(runqueue_t *runqueue) {
  unsigned int max_len = runqueue->high_watermark;
  runqueue->high_watermark = 0;
  return max_len;
}

inline int runqueue_empty_p(runqueue_t *runqueue) {
  return (runqueue->entries.count == 0);
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polyphony-0.65 ext/polyphony/runqueue.c
polyphony-0.64 ext/polyphony/runqueue.c
polyphony-0.63 ext/polyphony/runqueue.c
polyphony-0.62 ext/polyphony/runqueue.c