From b2acdc739309ba72617abc766010b762d758c6ec Mon Sep 17 00:00:00 2001 From: samskivert Date: Tue, 11 Aug 2009 21:08:47 +0000 Subject: [PATCH] Added isEmpty(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@2605 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/Invoker.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/java/com/samskivert/util/Invoker.java b/src/java/com/samskivert/util/Invoker.java index 8dcc3f1b..fdcd1d8d 100644 --- a/src/java/com/samskivert/util/Invoker.java +++ b/src/java/com/samskivert/util/Invoker.java @@ -153,6 +153,17 @@ public class Invoker extends LoopingThread _queue.append(unit); } + /** + * Returns true if this invoker has no pending units, false if it has pending units. + * Note: this does not account for whether a unit is currently being + * processed, so if you want to guarantee that an invoker is empty, it's best to call this + * method in a unit being processed by that invoker. + */ + public boolean isEmpty () + { + return _queue.size() == 0; + } + // from RunQueue public void postRunnable (final Runnable r) {