Merge branch 'master' of ecommons@wax.hive:bdberl

This commit is contained in:
Jon Meredith 2009-02-10 13:11:35 -07:00
commit 153d4615cd
3 changed files with 10 additions and 9 deletions

View file

@ -454,7 +454,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
d->async_flags = UNPACK_INT(inbuf, 0);
}
d->async_pool = G_TPOOL_TXNS;
d->async_job = bdberl_tpool_run(G_TPOOL_TXNS, &do_async_txnop, d, 0);
bdberl_tpool_run(d->async_pool, &do_async_txnop, d, 0, &d->async_job);
// Outbuf is <<Rc:32>>
RETURN_INT(0, outbuf);
@ -504,8 +504,8 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
fn = &do_async_get;
}
d->async_pool = G_TPOOL_GENERAL;
d->async_job = bdberl_tpool_run(G_TPOOL_GENERAL, fn, d, 0);
bdberl_tpool_run(d->async_pool, fn, d, 0, &d->async_job);
// Let caller know that the operation is in progress
// Outbuf is: <<0:32>>
RETURN_INT(0, outbuf);
@ -569,7 +569,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
// Schedule the operation
d->async_op = cmd;
d->async_pool = G_TPOOL_GENERAL;
d->async_job = bdberl_tpool_run(G_TPOOL_GENERAL, &do_async_cursor_get, d, 0);
bdberl_tpool_run(d->async_pool, &do_async_cursor_get, d, 0, &d->async_job);
// Let caller know operation is in progress
RETURN_INT(0, outbuf);
@ -636,7 +636,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
// Mark the port as busy and then schedule the appropriate async operation
d->async_op = cmd;
d->async_pool = G_TPOOL_GENERAL;
d->async_job = bdberl_tpool_run(G_TPOOL_GENERAL, &do_async_truncate, d, 0);
bdberl_tpool_run(d->async_pool, &do_async_truncate, d, 0, &d->async_job);
// Let caller know that the operation is in progress
// Outbuf is: <<0:32>>

View file

@ -74,10 +74,11 @@ void bdberl_tpool_stop(TPool* tpool)
driver_free(tpool);
}
TPoolJob* bdberl_tpool_run(TPool* tpool, TPoolJobFunc main_fn, void* arg, TPoolJobFunc cancel_fn)
void bdberl_tpool_run(TPool* tpool, TPoolJobFunc main_fn, void* arg, TPoolJobFunc cancel_fn,
TPoolJob** job_ptr)
{
// Allocate and fill a new job structure
TPoolJob* job = driver_alloc(sizeof(TPoolJob));
TPoolJob* job = *job_ptr = driver_alloc(sizeof(TPoolJob));
memset(job, '\0', sizeof(TPoolJob));
job->main_fn = main_fn;
job->arg = arg;
@ -105,7 +106,6 @@ TPoolJob* bdberl_tpool_run(TPool* tpool, TPoolJobFunc main_fn, void* arg, TPoolJ
// pending jobs. Not sure ATM, however, so will be on safe side
erl_drv_cond_broadcast(tpool->work_cv);
UNLOCK(tpool);
return job;
}
void bdberl_tpool_cancel(TPool* tpool, TPoolJob* job)

View file

@ -60,7 +60,8 @@ TPool* bdberl_tpool_start(unsigned int thread_count);
void bdberl_tpool_stop(TPool* tpool);
TPoolJob* bdberl_tpool_run(TPool* tpool, TPoolJobFunc main_fn, void* arg, TPoolJobFunc cancel_fn);
void bdberl_tpool_run(TPool* tpool, TPoolJobFunc main_fn, void* arg, TPoolJobFunc cancel_fn,
TPoolJob** job_ptr);
void bdberl_tpool_cancel(TPool* tpool, TPoolJob* job);