Commit 0f39e134 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

closes #5265, add comments for bjm and add lock around bjm_reset

git-svn-id: file:///svn/toku/tokudb@45853 c7de825b-a66e-492c-adef-691d508d4ae1
parent 046ce55a
...@@ -35,8 +35,10 @@ void bjm_destroy(BACKGROUND_JOB_MANAGER bjm) { ...@@ -35,8 +35,10 @@ void bjm_destroy(BACKGROUND_JOB_MANAGER bjm) {
} }
void bjm_reset(BACKGROUND_JOB_MANAGER bjm) { void bjm_reset(BACKGROUND_JOB_MANAGER bjm) {
toku_mutex_lock(&bjm->jobs_lock);
assert(bjm->num_jobs == 0); assert(bjm->num_jobs == 0);
bjm->accepting_jobs = true; bjm->accepting_jobs = true;
toku_mutex_unlock(&bjm->jobs_lock);
} }
int bjm_add_background_job(BACKGROUND_JOB_MANAGER bjm) { int bjm_add_background_job(BACKGROUND_JOB_MANAGER bjm) {
......
...@@ -7,14 +7,43 @@ ...@@ -7,14 +7,43 @@
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." #ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
//
// The background job manager keeps track of the existence of
// background jobs running. We use the background job manager
// to allow threads to perform background jobs on various pieces
// of the system (e.g. cachefiles and cloned pairs being written out
// for checkpoint)
//
typedef struct background_job_manager_struct *BACKGROUND_JOB_MANAGER; typedef struct background_job_manager_struct *BACKGROUND_JOB_MANAGER;
void bjm_init(BACKGROUND_JOB_MANAGER* bjm); void bjm_init(BACKGROUND_JOB_MANAGER* bjm);
void bjm_destroy(BACKGROUND_JOB_MANAGER bjm); void bjm_destroy(BACKGROUND_JOB_MANAGER bjm);
//
// Re-allows a background job manager to accept background jobs
//
void bjm_reset(BACKGROUND_JOB_MANAGER bjm); void bjm_reset(BACKGROUND_JOB_MANAGER bjm);
//
// add a background job. If return value is 0, then the addition of the job
// was successful and the user may perform the background job. If return
// value is non-zero, then adding of the background job failed and the user
// may not perform the background job.
//
int bjm_add_background_job(BACKGROUND_JOB_MANAGER bjm); int bjm_add_background_job(BACKGROUND_JOB_MANAGER bjm);
//
// remove a background job
//
void bjm_remove_background_job(BACKGROUND_JOB_MANAGER bjm); void bjm_remove_background_job(BACKGROUND_JOB_MANAGER bjm);
//
// This function waits for all current background jobs to be removed. If the user
// calls bjm_add_background_job while this function is running, or after this function
// has completed, bjm_add_background_job returns an error.
//
void bjm_wait_for_jobs_to_finish(BACKGROUND_JOB_MANAGER bjm); void bjm_wait_for_jobs_to_finish(BACKGROUND_JOB_MANAGER bjm);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment