Beispiel #1
0
 //
 // The destructor!
 //
 ~SpellDictionary(){
   if (spellClass){
     delete spellClass;
     spellClass = NULL;
   }
   uv_rwlock_destroy(&rwlock);
 };
Beispiel #2
0
static mrb_value
mrb_uv_rwlock_destroy(mrb_state *mrb, mrb_value self)
{
  uv_rwlock_destroy((uv_rwlock_t*)mrb_uv_get_ptr(mrb, self, &mrb_uv_rwlock_type));
  DATA_PTR(self) = NULL;
  return self;
}
Beispiel #3
0
static void
mrb_uv_rwlock_free(mrb_state *mrb, void *p)
{
  if (p) {
    uv_rwlock_destroy((uv_rwlock_t*)p);
    mrb_free(mrb, p);
  }
}
Beispiel #4
0
static void
RWLock_tp_dealloc(RWLock *self)
{
    if (self->initialized) {
        uv_rwlock_destroy(&self->uv_rwlock);
    }
    Py_TYPE(self)->tp_free(self);
}
Beispiel #5
0
void
php_cassandra_log_cleanup()
{
  cass_log_cleanup();
  uv_rwlock_destroy(&log_lock);
  if (log_location) {
    free(log_location);
    log_location = NULL;
  }
}
Beispiel #6
0
int main()
{
	uv_thread_t threads[3];
	int thread_nums[] = {1, 2, 1};

	uv_barrier_init(&blocker, 4);

	shared_num = 0;
	uv_rwlock_init(&numlock);

	uv_thread_create(&threads[0], reader, &thread_nums[0]);
	uv_thread_create(&threads[1], reader, &thread_nums[1]);
	uv_thread_create(&threads[2], writer, &thread_nums[2]);

	uv_barrier_wait(&blocker);
	uv_barrier_destroy(&blocker);

	uv_rwlock_destroy(&numlock);
	return 0;
}
Beispiel #7
0
// same as ./10-locks, but using try* functions when obtaining read and write locks
//
int main() {
  int r;
  const int count = 4;

  fprintf(stderr, "barrier: init\n");
  uv_barrier_init(&blocker, count);

  shared_num = 0;

  // https://github.com/thlorenz/libuv-dox/blob/master/methods.md#rwlock
  fprintf(stderr, "rwlock: init\n");
  r = uv_rwlock_init(&numlock);
  if (r) ERROR("rwlock_init", r);

  uv_thread_t threads[3];

  int thread_nums[] = { 1, 2, 1 };
  r = uv_thread_create(&threads[0], reader_entry, &thread_nums[0]);
  if (r) ERROR("thread_create", r);

  r = uv_thread_create(&threads[1], reader_entry, &thread_nums[1]);
  if (r) ERROR("thread_create", r);

  r = uv_thread_create(&threads[2], writer_entry, &thread_nums[2]);
  if (r) ERROR("thread_create", r);

  // https://github.com/thlorenz/libuv-dox/blob/master/methods.md#barrier
  fprintf(stderr, "barrier: wait\n");
  uv_barrier_wait(&blocker);

  fprintf(stderr, "barrier: destroy\n");
  uv_barrier_destroy(&blocker);

  fprintf(stderr, "rwlock: destroy\n");
  uv_rwlock_destroy(&numlock);
  if (r) ERROR("rwlock_destroy", r);

  return 0;
}
Beispiel #8
0
void uv__loop_close(uv_loop_t* loop) {
  uv__signal_loop_cleanup(loop);
  uv__platform_loop_delete(loop);
  uv__async_stop(loop);

  if (loop->emfile_fd != -1) {
    uv__close(loop->emfile_fd);
    loop->emfile_fd = -1;
  }

  if (loop->backend_fd != -1) {
    uv__close(loop->backend_fd);
    loop->backend_fd = -1;
  }

  uv_mutex_lock(&loop->wq_mutex);
  assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!");
  assert(!uv__has_active_reqs(loop));
  uv_mutex_unlock(&loop->wq_mutex);
  uv_mutex_destroy(&loop->wq_mutex);

  /*
   * Note that all thread pool stuff is finished at this point and
   * it is safe to just destroy rw lock
   */
  uv_rwlock_destroy(&loop->cloexec_lock);

#if 0
  assert(QUEUE_EMPTY(&loop->pending_queue));
  assert(QUEUE_EMPTY(&loop->watcher_queue));
  assert(loop->nfds == 0);
#endif

  uv__free(loop->watchers);
  loop->watchers = NULL;
  loop->nwatchers = 0;
}
Beispiel #9
0
int uv_loop_init(uv_loop_t* loop) {
  void* saved_data;
  int err;


  saved_data = loop->data;
  memset(loop, 0, sizeof(*loop));
  loop->data = saved_data;

  heap_init((struct heap*) &loop->timer_heap);
  QUEUE_INIT(&loop->wq);
  QUEUE_INIT(&loop->idle_handles);
  QUEUE_INIT(&loop->async_handles);
  QUEUE_INIT(&loop->check_handles);
  QUEUE_INIT(&loop->prepare_handles);
  QUEUE_INIT(&loop->handle_queue);

  loop->active_handles = 0;
  loop->active_reqs.count = 0;
  loop->nfds = 0;
  loop->watchers = NULL;
  loop->nwatchers = 0;
  QUEUE_INIT(&loop->pending_queue);
  QUEUE_INIT(&loop->watcher_queue);

  loop->closing_handles = NULL;
  uv__update_time(loop);
  loop->async_io_watcher.fd = -1;
  loop->async_wfd = -1;
  loop->signal_pipefd[0] = -1;
  loop->signal_pipefd[1] = -1;
  loop->backend_fd = -1;
  loop->emfile_fd = -1;

  loop->timer_counter = 0;
  loop->stop_flag = 0;

  err = uv__platform_loop_init(loop);
  if (err)
    return err;

  uv__signal_global_once_init();
  err = uv_signal_init(loop, &loop->child_watcher);
  if (err)
    goto fail_signal_init;

  uv__handle_unref(&loop->child_watcher);
  loop->child_watcher.flags |= UV__HANDLE_INTERNAL;
  QUEUE_INIT(&loop->process_handles);

  err = uv_rwlock_init(&loop->cloexec_lock);
  if (err)
    goto fail_rwlock_init;

  err = uv_mutex_init(&loop->wq_mutex);
  if (err)
    goto fail_mutex_init;

  err = uv_async_init(loop, &loop->wq_async, uv__work_done);
  if (err)
    goto fail_async_init;

  uv__handle_unref(&loop->wq_async);
  loop->wq_async.flags |= UV__HANDLE_INTERNAL;

  return 0;

fail_async_init:
  uv_mutex_destroy(&loop->wq_mutex);

fail_mutex_init:
  uv_rwlock_destroy(&loop->cloexec_lock);

fail_rwlock_init:
  uv__signal_loop_cleanup(loop);

fail_signal_init:
  uv__platform_loop_delete(loop);

  return err;
}
Beispiel #10
0
 ~SessionContainer() {
   uv_rwlock_destroy(&sessions_lock);
 }
Beispiel #11
0
 inline ~rwlock() { uv_rwlock_destroy(&mtx); }