summaryrefslogtreecommitdiff
path: root/taskflow/utils/threading_utils.py
diff options
context:
space:
mode:
authorIvan A. Melnikov <imelnikov@griddynamics.com>2013-10-14 19:09:24 +0400
committerIvan A. Melnikov <imelnikov@griddynamics.com>2013-10-14 19:09:24 +0400
commit009f9a17eadf6ebb8b106bd52a569274f334d0cb (patch)
tree8c33ecd42ec4c46e5b26fd17ddd10daf8f0b06de /taskflow/utils/threading_utils.py
parenta682717f734f1488306a4266cb8e18eb07faa9d4 (diff)
downloadtaskflow-009f9a17eadf6ebb8b106bd52a569274f334d0cb.tar.gz
Removed unused utilities
Change-Id: Ifa3e7b820d594303c6c02eae12f55bce2bd1dacc
Diffstat (limited to 'taskflow/utils/threading_utils.py')
-rw-r--r--taskflow/utils/threading_utils.py57
1 files changed, 0 insertions, 57 deletions
diff --git a/taskflow/utils/threading_utils.py b/taskflow/utils/threading_utils.py
index 692781c..bffd037 100644
--- a/taskflow/utils/threading_utils.py
+++ b/taskflow/utils/threading_utils.py
@@ -20,7 +20,6 @@ import logging
import multiprocessing
import six
import threading
-import time
import types
from taskflow.utils import lock_utils
@@ -28,26 +27,6 @@ from taskflow.utils import lock_utils
LOG = logging.getLogger(__name__)
-def await(check_functor, timeout=None):
- """Spin-loops + sleeps awaiting for a given functor to return true."""
- if timeout is not None:
- end_time = time.time() + max(0, timeout)
- else:
- end_time = None
- # Use the same/similar scheme that the python condition class uses.
- delay = 0.0005
- while not check_functor():
- time.sleep(delay)
- if end_time is not None:
- remaining = end_time - time.time()
- if remaining <= 0:
- return False
- delay = min(delay * 2, remaining, 0.05)
- else:
- delay = min(delay * 2, 0.05)
- return True
-
-
def get_optimal_thread_count():
"""Try to guess optimal thread count for current system."""
try:
@@ -59,42 +38,6 @@ def get_optimal_thread_count():
return 2
-class CountDownLatch(object):
- """Similar in concept to the java count down latch."""
-
- def __init__(self, count=0):
- self.count = count
- self.lock = threading.Condition()
-
- def countDown(self):
- with self.lock:
- self.count -= 1
- if self.count <= 0:
- self.lock.notifyAll()
-
- def await(self, timeout=None):
- end_time = None
- if timeout is not None:
- timeout = max(0, timeout)
- end_time = time.time() + timeout
- time_up = False
- with self.lock:
- while True:
- # Stop waiting on these 2 conditions.
- if time_up or self.count <= 0:
- break
- # Was this a spurious wakeup or did we really end??
- self.lock.wait(timeout=timeout)
- if end_time is not None:
- if time.time() >= end_time:
- time_up = True
- else:
- # Reduce the timeout so that we don't wait extra time
- # over what we initially were requested to.
- timeout = end_time - time.time()
- return self.count <= 0
-
-
class ThreadSafeMeta(type):
"""Metaclass that adds locking to all pubic methods of a class"""