thread conditional code
Steve Purcell
stephen_purcell at yahoo.com
Sat Apr 14 06:42:22 EDT 2001
Robin Becker wrote:
> It seems that using a lock requires the threading overhead; so is there
> any way to avoid locking when threading hasn't been started? I guess I
> would like to know if thread.c's initialized variable is true / false.
>
> That way I could conditionally lock access to contentious variables and
> avoid thread overhead when not needed.
But would such conditional locking code be thread-safe?
if threading_started:
lock()
# threading could start here
code_that_should_run_safely()
I would expect the OS' threading libraries to take care of minimising
threading overhead in the case where only one thread is running.
-Steve
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo
More information about the Python-list
mailing list