Commit Graph

5 Commits

Author SHA1 Message Date
Ali Ijaz Sheikh
3af6f17241 test: add uv_barrier_wait serial thread test
Ensure that uv_barrier_wait returns positive only after all threads have
exited the barrier. If this value is returned too early and the barrier
is destroyed prematurely, then this test may see a crash.

PR-URL: https://github.com/libuv/libuv/pull/2019
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-08 11:14:41 +02:00
Saúl Ibarra Corretgé
1830a3cd91 Revert "test: make barrier test more rigorous"
This reverts commit 6c6c922167.

It introduced a race condition which made tests fail on Linux and SunOS.

Closes #1340
2014-07-02 00:16:50 +02:00
Ben Noordhuis
6c6c922167 test: make barrier test more rigorous
A correct barriers implementation blocks in uv_barrier_destroy() until
the last thread returns from uv_barrier_wait() so make the test more
rigorous by destroying the barrier straight away instead of first
joining the worker thread.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-07 07:57:10 -07:00
Ben Noordhuis
91985d48f6 unix, windows: make uv_barrier_wait() return bool
Make uv_barrier_wait() return a boolean value indicating whether this
thread was the "serializer".

From `man pthread_barrier_wait`:

    Upon successful completion, the pthread_barrier_wait() function
    shall return PTHREAD_BARRIER_SERIAL_THREAD for a single (arbitrary)
    thread synchronized at the barrier and zero for each of the other
    threads.

Exposing that information from libuv is useful because it can make
cleanup significantly easier:

    if (uv_barrier_wait(&barrier) > 0)
      uv_barrier_destroy(&barrier);

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-07 07:57:08 -07:00
Hiroaki Nakamura
acea3028c5 unix, windows: add thread barrier support 2012-10-09 17:30:52 +02:00