path: root/run-command.h
diff options
authorJeff King <>2015-09-01 20:22:43 (GMT)
committerJunio C Hamano <>2015-09-01 22:11:53 (GMT)
commit661a8cf408e83e4901bf09e2a48e9306622442dd (patch)
treef9bb2bd593d27765d0c23fe236ede6342e052f86 /run-command.h
parent323598387d900263c4980b43b8a96c43cdd7b6c7 (diff)
run-command: provide in_async query function
It's not easy for arbitrary code to find out whether it is running in an async process or not. A top-level function which is fed to start_async() can know (you just pass down an argument saying "you are async"). But that function may call other global functions, and we would not want to have to pass the information all the way through the call stack. Nor can we simply set a global variable, as those may be shared between async threads and the main thread (if the platform supports pthreads). We need pthread tricks _or_ a global variable, depending on how start_async is implemented. The callers don't have enough information to do this right, so let's provide a simple query function that does. Fortunately we can reuse the existing infrastructure to make the pthread case simple (and even simplify die_async() by using our new function). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'run-command.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/run-command.h b/run-command.h
index 1103805..4aaac7c 100644
--- a/run-command.h
+++ b/run-command.h
@@ -113,5 +113,6 @@ struct async {
int start_async(struct async *async);
int finish_async(struct async *async);
+int in_async(void);