ext/iodine/fio.c
/* returned a locked arena. Attempts the preffered arena first. */
returned a locked arena. Attempts the preffered arena first.
returned a locked arena . Attempts the preffered arena first .
static inline arena_s *arena_lock(arena_s *preffered) {
  if (!preffered)
    preffered = arenas;
  if (!fio_trylock(&preffered->lock))
    return preffered;
  do {
    arena_s *arena = preffered;
    for (size_t i = (size_t)(arena - arenas); i < memory.cores; ++i) {
      if ((preffered == arenas || arena != preffered) &&
          !fio_trylock(&arena->lock))
        return arena;
      ++arena;
    }
    if (preffered == arenas)
      fio_reschedule_thread();
    preffered = arenas;
  } while (1);
}
static inline arena_s * arena_lock ( arena_s * preffered ) { if ( ! preffered ) preffered = arenas ; if ( ! fio_trylock ( & preffered -> lock ) ) return preffered ; do { arena_s * arena = preffered ; for ( size_t i = ( size_t ) ( arena - arenas ) ; i < memory . cores ; ++ i ) { if ( ( preffered == arenas || arena != preffered ) && ! fio_trylock ( & arena -> lock ) ) return arena ; ++ arena ; } if ( preffered == arenas ) fio_reschedule_thread ( ) ; preffered = arenas ; } while ( 1 ) ; }
returned a locked arena.
returned a locked arena .