Sha256: 140c48c3701b5a8faaed75b78d5b182d549aebe1985b706f0f739303ff8709fa

Contents?: true

Size: 1.59 KB

Versions: 6778

Compression:

Stored size: 1.59 KB

Contents

#include "byebug.h"

/**
 * A simple linked list containing locked threads, FIFO style.
 */

typedef struct locked_thread_t
{
  VALUE thread;
  struct locked_thread_t *next;
} locked_thread_t;

static locked_thread_t *locked_head = NULL;
static locked_thread_t *locked_tail = NULL;

static int
is_in_locked(VALUE thread)
{
  locked_thread_t *node;

  if (!locked_head)
    return 0;

  for (node = locked_head; node != locked_tail; node = node->next)
    if (node->thread == thread)
      return 1;

  return 0;
}

extern void
byebug_add_to_locked(VALUE thread)
{
  locked_thread_t *node;

  if (is_in_locked(thread))
    return;

  node = ALLOC(locked_thread_t);
  node->thread = thread;
  node->next = NULL;

  if (locked_tail)
    locked_tail->next = node;

  locked_tail = node;

  if (!locked_head)
    locked_head = node;
}

extern VALUE
byebug_pop_from_locked()
{
  VALUE thread;
  locked_thread_t *node;

  if (!locked_head)
    return Qnil;

  node = locked_head;
  locked_head = locked_head->next;

  if (locked_tail == node)
    locked_tail = NULL;

  thread = node->thread;
  xfree(node);

  return thread;
}

extern void
byebug_remove_from_locked(VALUE thread)
{
  locked_thread_t *node;
  locked_thread_t *next_node;

  if (NIL_P(thread) || !locked_head || !is_in_locked(thread))
    return;

  if (locked_head->thread == thread)
  {
    byebug_pop_from_locked();
    return;
  }

  for (node = locked_head; node != locked_tail; node = node->next)
    if (node->next && node->next->thread == thread)
    {
      next_node = node->next;
      node->next = next_node->next;
      xfree(next_node);
      return;
    }
}

Version data entries

6,778 entries across 6,774 versions & 33 rubygems

Version Path
cybrid_api_organization_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_bank_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_organization_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_bank_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_organization_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_bank_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_organization_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_bank_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_organization_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
avalara_sdk-24.12.0 vendor/bundle/ruby/2.7.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_bank_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_organization_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_bank_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c
cybrid_api_id_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/ext/byebug/locker.c