From 12d81c970f058c728051d5e3520cafcc15368a52 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 21 Feb 2015 19:44:45 -0800 Subject: [PATCH] Tweak some of the types thread safety docstrings Change-Id: I27f920007f5a311906257809eca26a60f8e9a386 --- taskflow/types/notifier.py | 10 +++++++++- taskflow/types/timing.py | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/taskflow/types/notifier.py b/taskflow/types/notifier.py index 77dbbc0d..eaf7b02c 100644 --- a/taskflow/types/notifier.py +++ b/taskflow/types/notifier.py @@ -70,7 +70,8 @@ class _Listener(object): def __repr__(self): repr_msg = "%s object at 0x%x calling into '%r'" % ( - reflection.get_class_name(self), id(self), self._callback) + reflection.get_class_name(self, fully_qualified=False), + id(self), self._callback) if self._details_filter is not None: repr_msg += " using details filter '%r'" % self._details_filter return "<%s>" % repr_msg @@ -109,6 +110,13 @@ class Notifier(object): occurring as well as allow a entity to post said notifications to any associated subscribers without having either entity care about how this notification occurs. + + **Not** thread-safe when a single notifier is mutated at the same + time by multiple threads. For example having multiple threads call + into :py:meth:`.register` or :py:meth:`.reset` at the same time could + potentially end badly. It is thread-safe when + only :py:meth:`.notify` calls or other read-only actions (like calling + into :py:meth:`.is_registered`) are occuring at the same time. """ #: Keys that can *not* be used in callbacks arguments diff --git a/taskflow/types/timing.py b/taskflow/types/timing.py index e22b2da0..0dad971f 100644 --- a/taskflow/types/timing.py +++ b/taskflow/types/timing.py @@ -82,10 +82,10 @@ class StopWatch(object): Inspired by: apache-commons-lang java stopwatch. - Not thread-safe (when a single watch is mutated by multiple threads at - the same time). Thread-safe when used by a single thread (not shared) or - when operations are performed in a thread-safe manner on these objects by - wrapping those operations with locks. + **Not** thread-safe (when a single watch is mutated by multiple threads at + the same time). It is thread-safe when used by a single thread (not + shared) or when operations are performed in a thread-safe manner on these + objects by wrapping those operations with locks. """ _STARTED = 'STARTED' _STOPPED = 'STOPPED'