Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Allow queue creation to specify mutex/condvar names
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter Morris committed Mar 13, 2012
1 parent f98feb6 commit 1464108
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions c_src/async_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "async_queue.h"

async_queue_t*
async_queue_create()
async_queue_create(char* mutex_name, char* condvar_name)
{
async_queue_t *aq;

Expand All @@ -52,13 +52,13 @@ async_queue_create()

aq->waiting_threads = aq->len = 0;

aq->mutex = enif_mutex_create("erlang_snappy_mutex");
aq->mutex = enif_mutex_create(mutex_name);

if (!aq->mutex) {
errx(1, "enif_mutex_create() failed");
}

aq->cond = enif_cond_create("erlang_snappy_condvar");
aq->cond = enif_cond_create(condvar_name);

if (!aq->cond) {
errx(1, "enif_cond_create() failed");
Expand Down
2 changes: 1 addition & 1 deletion c_src/async_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct __async_queue {
int len;
} async_queue_t;

async_queue_t* async_queue_create();
async_queue_t* async_queue_create(char* mutex_name, char* condvar_name);
int async_queue_length(async_queue_t *aq);
void* async_queue_pop(async_queue_t *aq);
void async_queue_push(async_queue_t *aq, void *data);
Expand Down
2 changes: 1 addition & 1 deletion c_src/bcrypt_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static ERL_NIF_TERM bcrypt_create_ctx(ErlNifEnv* env, int argc, const ERL_NIF_TE
ctx_t* ctx = (ctx_t*)enif_alloc_resource(priv->bcrypt_rt, sizeof(ctx_t));
if (ctx == NULL)
return enif_make_badarg(env);
ctx->queue = async_queue_create();
ctx->queue = async_queue_create("bcrypt_queue_mutex", "bcrypt_queue_condvar");
ctx->topts = enif_thread_opts_create("bcrypt_thread_opts");
if (enif_thread_create("bcrypt_worker", &ctx->tid, async_worker, ctx, ctx->topts) != 0) {
enif_release_resource(ctx);
Expand Down

0 comments on commit 1464108

Please sign in to comment.