summaryrefslogtreecommitdiff
path: root/deps/uv/test/benchmark-async-pummel.c
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-10-30 23:06:03 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-11-01 01:22:16 +0100
commitab1e66d93f4eddf23f62fd69094690124357e3e9 (patch)
tree7c5cc31b101f713fc23e828751b9eef8be573f5e /deps/uv/test/benchmark-async-pummel.c
parenta12c42ca2f8d5ce71c75cab334a53bd71bdaea09 (diff)
downloadandroid-node-v8-ab1e66d93f4eddf23f62fd69094690124357e3e9.tar.gz
android-node-v8-ab1e66d93f4eddf23f62fd69094690124357e3e9.tar.bz2
android-node-v8-ab1e66d93f4eddf23f62fd69094690124357e3e9.zip
deps: upgrade libuv to 97c527a
Diffstat (limited to 'deps/uv/test/benchmark-async-pummel.c')
-rw-r--r--deps/uv/test/benchmark-async-pummel.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/deps/uv/test/benchmark-async-pummel.c b/deps/uv/test/benchmark-async-pummel.c
index c83821322e..49cf442b08 100644
--- a/deps/uv/test/benchmark-async-pummel.c
+++ b/deps/uv/test/benchmark-async-pummel.c
@@ -32,14 +32,27 @@ static volatile int done;
static void async_cb(uv_async_t* handle, int status) {
- if (++callbacks == NUM_PINGS)
+ if (++callbacks == NUM_PINGS) {
+ /* Tell the pummel thread to stop. */
+ handle->data = (void*) (intptr_t) 1;
+
+ /* Wait for for the pummel thread to acknowledge that it has stoppped. */
+ while (*(volatile intptr_t*) &handle->data < 2)
+ uv_sleep(0);
+
uv_close((uv_handle_t*) handle, NULL);
+ }
}
static void pummel(void* arg) {
- while (!done)
- uv_async_send((uv_async_t*) arg);
+ uv_async_t* handle = (uv_async_t*) arg;
+
+ while (*(volatile intptr_t*) &handle->data == 0)
+ uv_async_send(handle);
+
+ /* Acknowledge that we've seen handle->data change. */
+ handle->data = (void*) (intptr_t) 2;
}
@@ -53,6 +66,7 @@ static int test_async_pummel(int nthreads) {
ASSERT(tids != NULL);
ASSERT(0 == uv_async_init(uv_default_loop(), &handle, async_cb));
+ handle.data = NULL;
for (i = 0; i < nthreads; i++)
ASSERT(0 == uv_thread_create(tids + i, pummel, &handle));