From 5b5d39601b2a58abec6359c7afe098de4e34c280 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 30 Jun 2008 11:36:17 +0000 Subject: [PATCH] Added requireEventThread and refuseEventThread. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5213 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/PresentsDObjectMgr.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java index 32c7dc5c6..a7e4d5b26 100644 --- a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java +++ b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java @@ -275,6 +275,30 @@ public class PresentsDObjectMgr return Thread.currentThread() == _dobjThread; } + /** + * Ensures that the calling thread is the distributed object event dispatch thread, throwing an + * {@link IllegalStateException} if it is not. + */ + public void requireEventThread () + { + if (!isDispatchThread()) { + String errmsg = "This method must be called on the dobj event thread."; + throw new IllegalStateException(errmsg); + } + } + + /** + * Ensures that the calling thread is not the distributed object event dispatch + * thread, throwing an {@link IllegalStateException} if it is. + */ + public void refuseEventThread () + { + if (isDispatchThread()) { + String errmsg = "This method must not be called on the dobj event thread."; + throw new IllegalStateException(errmsg); + } + } + /** * Runs the dobjmgr event loop until it is requested to exit. This should be called from the * main application thread.