From: Johannes Sixt <j6t@kdbg.org>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH 7/6] Enable threaded async procedures whenever pthreads is available
Date: Tue, 9 Mar 2010 21:00:36 +0100 [thread overview]
Message-ID: <201003092100.36616.j6t@kdbg.org> (raw)
In-Reply-To: <20100306215051.GE2529@spearce.org>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
On Samstag, 6. März 2010, Shawn O. Pearce wrote:
> I'm in favor of that. If we have threaded delta search enabled,
> we probably can also run these async procedures in a POSIX thread
> rather than forking off a child.
OK. The patch could look like this.
-- Hannes
Documentation/technical/api-run-command.txt | 5 +++--
Makefile | 5 -----
run-command.c | 6 +++---
run-command.h | 4 ++--
4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
index 44876fa..f18b4f4 100644
--- a/Documentation/technical/api-run-command.txt
+++ b/Documentation/technical/api-run-command.txt
@@ -231,8 +231,9 @@ The function pointer in .proc has the following signature:
There are serious restrictions on what the asynchronous function can do
-because this facility is implemented by a pipe to a forked process on
-UNIX, but by a thread in the same address space on Windows:
+because this facility is implemented by a thread in the same address
+space on most platforms (when pthreads is available), but by a pipe to
+a forked process otherwise:
. It cannot change the program's state (global variables, environment,
etc.) in a way that the caller notices; in other words, .in and .out
diff --git a/Makefile b/Makefile
index 2fe52f8..52f2cc0 100644
--- a/Makefile
+++ b/Makefile
@@ -979,7 +979,6 @@ ifeq ($(uname_S),Windows)
NO_CURL = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
- ASYNC_AS_THREAD = YesPlease
CC = compat/vcbuild/scripts/clink.pl
AR = compat/vcbuild/scripts/lib.pl
@@ -1031,7 +1030,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_REGEX = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
- ASYNC_AS_THREAD = YesPlease
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
@@ -1344,9 +1342,6 @@ ifdef NO_PTHREADS
else
EXTLIBS += $(PTHREAD_LIBS)
LIB_OBJS += thread-utils.o
-ifdef ASYNC_AS_THREAD
- BASIC_CFLAGS += -DASYNC_AS_THREAD
-endif
endif
ifdef DIR_HAS_BSD_GROUP_SEMANTICS
diff --git a/run-command.c b/run-command.c
index 66cc4bf..053b28f 100644
--- a/run-command.c
+++ b/run-command.c
@@ -447,7 +447,7 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
return run_command(&cmd);
}
-#ifdef ASYNC_AS_THREAD
+#ifndef NO_PTHREADS
static pthread_t main_thread;
static int main_thread_set;
static pthread_key_t async_key;
@@ -521,7 +521,7 @@ int start_async(struct async *async)
else
proc_out = -1;
-#ifndef ASYNC_AS_THREAD
+#ifdef NO_PTHREADS
/* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL);
@@ -590,7 +590,7 @@ error:
int finish_async(struct async *async)
{
-#ifndef ASYNC_AS_THREAD
+#ifdef NO_PTHREADS
return wait_or_whine(async->pid, "child process", 0);
#else
void *ret = (void *)(intptr_t)(-1);
diff --git a/run-command.h b/run-command.h
index 40db39c..56491b9 100644
--- a/run-command.h
+++ b/run-command.h
@@ -1,7 +1,7 @@
#ifndef RUN_COMMAND_H
#define RUN_COMMAND_H
-#ifdef ASYNC_AS_THREAD
+#ifndef NO_PTHREADS
#include <pthread.h>
#endif
@@ -78,7 +78,7 @@ struct async {
void *data;
int in; /* caller writes here and closes it */
int out; /* caller reads from here and closes it */
-#ifndef ASYNC_AS_THREAD
+#ifdef NO_PTHREADS
pid_t pid;
#else
pthread_t tid;
--
1.7.0.rc2.65.g7b13a
next prev parent reply other threads:[~2010-03-09 20:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-06 15:40 [PATCH 0/6] Pass t5530 on Windows Johannes Sixt
2010-03-06 20:12 ` Junio C Hamano
2010-03-06 21:50 ` Shawn O. Pearce
2010-03-09 20:00 ` Johannes Sixt [this message]
2010-03-09 23:43 ` [PATCH 7/6] Enable threaded async procedures whenever pthreads is available Shawn O. Pearce
2010-03-10 22:28 ` Junio C Hamano
2010-03-11 19:53 ` Johannes Sixt
2010-03-12 5:56 ` Junio C Hamano
2010-03-17 21:28 ` Johannes Sixt
2010-03-17 22:19 ` Junio C Hamano
2010-03-23 8:15 ` Fredrik Kuivinen
2010-03-23 20:19 ` Johannes Sixt
2010-03-23 20:25 ` Johannes Sixt
2010-03-23 20:44 ` Junio C Hamano
2010-03-23 21:09 ` Johannes Sixt
2010-03-23 21:42 ` Fredrik Kuivinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201003092100.36616.j6t@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.