minor performance tweak.

This commit is contained in:
Heng Sin Low 2012-12-03 15:04:10 +08:00
parent 75c8695aa8
commit 87a3c1ac23
2 changed files with 20 additions and 1 deletions

View File

@ -2604,7 +2604,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{ {
try try
{ {
Thread.sleep(100); // .1 sec m_mTable.waitLoading(100); // .1 sec
} }
catch (Exception e) {} catch (Exception e) {}
count = m_mTable.getRowCount(); count = m_mTable.getRowCount();

View File

@ -35,8 +35,10 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.event.TableModelListener; import javax.swing.event.TableModelListener;
@ -689,6 +691,23 @@ public class GridTable extends AbstractTableModel
return false; return false;
} // isLoading } // isLoading
/**
* wait for the loading of data
* @param timeout timeout in milisecond. pass 0 or negative value for infinite wait
* @throws InterruptedException
* @throws ExecutionException
* @throws TimeoutException
*/
public void waitLoading(long timeout) throws InterruptedException, ExecutionException, TimeoutException
{
if (m_loaderFuture != null && !m_loaderFuture.isDone()) {
if (timeout > 0)
m_loaderFuture.get(timeout, TimeUnit.MILLISECONDS);
else
m_loaderFuture.get();
}
}
/** /**
* Is it open? * Is it open?
* @return true if opened * @return true if opened