Author: Armin Rigo <ar...@tunes.org> Branch: queue Changeset: r1860:d083e426a17d Date: 2015-06-18 14:45 +0200 http://bitbucket.org/pypy/stmgc/changeset/d083e426a17d/
Log: Clarify the return value of join() diff --git a/c8/stm/queue.c b/c8/stm/queue.c --- a/c8/stm/queue.c +++ b/c8/stm/queue.c @@ -309,7 +309,7 @@ seg->unfinished_tasks_in_this_transaction--; } -int stm_queue_join(object_t *qobj, stm_queue_t *queue, stm_thread_local_t *tl) +long stm_queue_join(object_t *qobj, stm_queue_t *queue, stm_thread_local_t *tl) { int64_t result; @@ -317,8 +317,7 @@ result = queue->unfinished_tasks; /* can't wait in tests */ result += (queue->segs[STM_SEGMENT->segment_num - 1] .unfinished_tasks_in_this_transaction); - if (result > 0) - return 42; + return result; #else STM_PUSH_ROOT(*tl, qobj); _stm_commit_transaction(); @@ -333,8 +332,9 @@ STM_POP_ROOT(*tl, qobj); /* 'queue' should stay alive until here */ #endif - /* returns 1 for 'ok', or 0 for error: negative 'unfinished_tasks' */ - return (result == 0); + /* returns 0 for 'ok', or negative if there was more task_done() + than put() so far */ + return result; } static void queue_trace_list(queue_entry_t *entry, void trace(object_t **), diff --git a/c8/stmgc.h b/c8/stmgc.h --- a/c8/stmgc.h +++ b/c8/stmgc.h @@ -751,7 +751,7 @@ void stm_queue_task_done(stm_queue_t *queue); /* join() commits and waits outside a transaction (so push roots). Unsuitable if the current transaction is atomic! */ -int stm_queue_join(object_t *qobj, stm_queue_t *queue, stm_thread_local_t *tl); +long stm_queue_join(object_t *qobj, stm_queue_t *queue, stm_thread_local_t *tl); void stm_queue_tracefn(stm_queue_t *queue, void trace(object_t **)); diff --git a/c8/test/test_queue.py b/c8/test/test_queue.py --- a/c8/test/test_queue.py +++ b/c8/test/test_queue.py @@ -59,12 +59,12 @@ def join(self, obj): q = get_queue(obj) res = lib.stm_queue_join(obj, q, self.tls[self.current_thread]); - if res == 1: + if res == 0: return - elif res == 42: + elif res > 0: raise Conflict("join() cannot wait in tests") else: - raise AssertionError("stm_queue_join error") + raise AssertionError("too much task_done()!") class TestQueue(BaseTestQueue): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit