Browse Source

Defer the execution of the callback associated to a request after the handle's
lock is released, so that the callback may also submit request to the handle
(or simply release the data for instance).

Cédric Augonnet 15 years ago
parent
commit
6c24cd5dc7
1 changed files with 10 additions and 7 deletions
  1. 10 7
      src/datawizard/data_request.c

+ 10 - 7
src/datawizard/data_request.c

@@ -253,6 +253,16 @@ static void starpu_handle_data_request_completion(starpu_data_request_t r)
 
 	/* In case there are one or multiple callbacks, we execute them now. */
 	struct callback_list *callbacks = r->callbacks;
+	
+	_starpu_spin_unlock(&r->lock);
+
+	if (do_delete)
+		starpu_data_request_destroy(r);
+
+	_starpu_spin_unlock(&handle->header_lock);
+
+	/* We do the callback once the lock is released so that they can do
+	 * blocking operations with the handle (eg. release it) */
 	while (callbacks)
 	{
 		callbacks->callback_func(callbacks->callback_arg);
@@ -261,13 +271,6 @@ static void starpu_handle_data_request_completion(starpu_data_request_t r)
 		free(callbacks);
 		callbacks = next;
 	}
-
-	_starpu_spin_unlock(&r->lock);
-
-	if (do_delete)
-		starpu_data_request_destroy(r);
-
-	_starpu_spin_unlock(&handle->header_lock);
 }
 
 /* TODO : accounting to see how much time was spent working for other people ... */