summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/webkitpy/common/thread
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-26 10:11:43 +0100
committerSteve Block <steveblock@google.com>2010-05-27 11:14:42 +0100
commite78cbe89e6f337f2f1fe40315be88f742b547151 (patch)
treed778000b84a04f24bbad50c7fa66244365e960e9 /WebKitTools/Scripts/webkitpy/common/thread
parent7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff)
downloadexternal_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/common/thread')
-rw-r--r--WebKitTools/Scripts/webkitpy/common/thread/threadedmessagequeue.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/WebKitTools/Scripts/webkitpy/common/thread/threadedmessagequeue.py b/WebKitTools/Scripts/webkitpy/common/thread/threadedmessagequeue.py
index 6cb6f8c..17b6277 100644
--- a/WebKitTools/Scripts/webkitpy/common/thread/threadedmessagequeue.py
+++ b/WebKitTools/Scripts/webkitpy/common/thread/threadedmessagequeue.py
@@ -26,6 +26,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from __future__ import with_statement
+
import threading
@@ -36,20 +38,17 @@ class ThreadedMessageQueue(object):
self._lock = threading.Lock()
def post(self, message):
- self._lock.acquire()
- self._messages.append(message)
- self._lock.release()
+ with self._lock:
+ self._messages.append(message)
def stop(self):
- self._lock.acquire()
- self._is_running = False
- self._lock.release()
+ with self._lock:
+ self._is_running = False
def take_all(self):
- self._lock.acquire()
- messages = self._messages
- is_running = self._is_running
- self._messages = []
- self._lock.release()
+ with self._lock:
+ messages = self._messages
+ is_running = self._is_running
+ self._messages = []
return (messages, is_running)