<commit_before>#include "rb-registry.h"
#include <ruby.h>
#include <pthread.h>
#include <stdatomic.h>

// #define RUBY_REG_DBG

// the registry global
static struct Registry {
  struct Object* obj_pool;
  struct Object* first;
  VALUE owner;
  atomic_bool lock;
} registry = {.obj_pool = NULL, .first = NULL, .owner = 0};

#define try_lock_registry() atomic_exchange(&registry.lock, 1)
#define unlock_registry() atomic_store(&registry.lock, 0)
#define lock_registry()         \
  {                             \
    while (try_lock_registry()) \
      sched_yield();            \
  }

// the references struct (bin-tree)
struct Object {
  struct Object* next;
  VALUE obj;
  int count;
};<commit_msg>biz atomic (no atomic)<commit_after>#include "rb-registry.h"
#include <ruby.h>
#include "spnlock.h"

// #define RUBY_REG_DBG

// the registry global
static struct Registry {
  struct Object* obj_pool;
  struct Object* first;
  VALUE owner;
  spn_lock_i lock;
} registry = {.obj_pool = NULL,
              .first = NULL,
              .owner = 0,
              .lock = SPN_LOCK_INIT};

#define try_lock_registry() spn_trylock(&registry.lock)
#define unlock_registry() spn_unlock(&registry.lock)
#define lock_registry() spn_lock(&registry.lock)

// the references struct (bin-tree)
struct Object {
  struct Object* next;
  VALUE obj;
  int count;
};
{'fraction_non_alphanumeric': 0.12472160356347439, 'fraction_numerical': 0.002969561989606533, 'mean_word_length': 3.1733746130030958, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2725540', 'n_tokens_mistral': 458, 'n_tokens_neox': 439, 'n_words': 117}