diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-06-09 13:20:07 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-06-09 13:20:07 +0100 |
commit | 5c0fd7b976b8fb1271dbe61b9ea456672ab5b370 (patch) | |
tree | 3bd0e95e47d36ba46c94342c9b7624ed81e82357 /examples/network/fetch.c | |
parent | bb502fa803605bcfce08da5467e52813eff4d38d (diff) | |
download | libgit2-5c0fd7b976b8fb1271dbe61b9ea456672ab5b370.tar.gz |
allow disabling pthreads for testing
Diffstat (limited to 'examples/network/fetch.c')
-rw-r--r-- | examples/network/fetch.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c index 8dcb81b1f..fc4e94cfd 100644 --- a/examples/network/fetch.c +++ b/examples/network/fetch.c @@ -36,7 +36,9 @@ static void *download(void *ptr) exit: data->finished = 1; +#ifndef NO_PTHREADS pthread_exit(&data->ret); +#endif } int update_cb(const char *refname, const git_oid *a, const git_oid *b) @@ -81,6 +83,9 @@ int fetch(git_repository *repo, int argc, char **argv) data.finished = 0; memset(&stats, 0, sizeof(stats)); +#ifdef NO_PTHREADS + download(&data); +#else pthread_create(&worker, NULL, download, &data); // Loop while the worker thread is still running. Here we show processed @@ -91,6 +96,7 @@ int fetch(git_repository *repo, int argc, char **argv) usleep(10000); printf("\rReceived %d/%d objects in %d bytes", stats.processed, stats.total, bytes); } while (!data.finished); +#endif printf("\rReceived %d/%d objects in %d bytes\n", stats.processed, stats.total, bytes); // Disconnect the underlying connection to prevent from idling. |