Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions c/src/ml-api-inference-single.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ invoke_thread (void *arg)
}

single_h->input = single_h->output = NULL;
g_cond_broadcast (&single_h->cond);
} else if (single_h->state == RUNNING)
single_h->state = IDLE;
g_mutex_unlock (&single_h->mutex);
Expand Down Expand Up @@ -1335,7 +1336,6 @@ int
ml_single_close (ml_single_h single)
{
ml_single *single_h;
gboolean invoking;

check_feature_state (ML_FEATURE_INFERENCE);

Expand All @@ -1350,21 +1350,12 @@ ml_single_close (ml_single_h single)

single_h->state = JOIN_REQUESTED;
g_cond_broadcast (&single_h->cond);
invoking = single_h->invoking;
ML_SINGLE_HANDLE_UNLOCK (single_h);

/** Wait until invoke process is finished */
while (invoking) {
_ml_logd ("Wait 1 ms until invoke is finished and close the handle.");
g_usleep (1000);
invoking = single_h->invoking;
/**
* single_h->invoking is the only protected value here and we are
* doing a read-only operation and do not need to project its value
* after the assignment.
* Thus, we do not need to lock single_h here.
*/
while (single_h->invoking) {
_ml_logd ("Wait until invoke is finished and close the handle.");
g_cond_wait (&single_h->cond, &single_h->mutex);
}
ML_SINGLE_HANDLE_UNLOCK (single_h);

if (single_h->thread != NULL)
g_thread_join (single_h->thread);
Expand Down
Loading