Permalink
Browse files

Allow queue creation to specify mutex/condvar names

  • Loading branch information...
1 parent f98feb6 commit 14641089aa8ad8f9c17886c3ecf534868a282431 Hunter Morris committed Mar 13, 2012
Showing with 5 additions and 5 deletions.
  1. +3 −3 c_src/async_queue.c
  2. +1 −1 c_src/async_queue.h
  3. +1 −1 c_src/bcrypt_nif.c
View
@@ -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;
@@ -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");
View
@@ -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);
View
@@ -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);

0 comments on commit 1464108

Please sign in to comment.