diff options
author | Eugene Tarassov | 2012-04-18 16:13:27 +0000 |
---|---|---|
committer | Eugene Tarassov | 2012-04-18 16:13:27 +0000 |
commit | 1a9d44e7c35bf78e3723b5328584271beba6cd9d (patch) | |
tree | 9186c0343fcb0663d4993ea97d3d19abbe967de0 /plugins | |
parent | 6e7c7126a21e638d0d47f69c7d55a3db3726548e (diff) | |
download | org.eclipse.tcf-1a9d44e7c35bf78e3723b5328584271beba6cd9d.tar.gz org.eclipse.tcf-1a9d44e7c35bf78e3723b5328584271beba6cd9d.tar.xz org.eclipse.tcf-1a9d44e7c35bf78e3723b5328584271beba6cd9d.zip |
TCF Core: a bit more efficient scheduling of data cache items
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/util/TCFDataCache.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/util/TCFDataCache.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/util/TCFDataCache.java index 6f1038c17..d70fafe22 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/util/TCFDataCache.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/util/TCFDataCache.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,6 +46,8 @@ import org.eclipse.tcf.protocol.Protocol; */ public abstract class TCFDataCache<V> implements Runnable { + private final int WAITING_LIST_SIZE = 8; + private Throwable error; private boolean valid; private boolean posted; @@ -125,10 +127,23 @@ public abstract class TCFDataCache<V> implements Runnable { waiting_cnt = 0; for (int i = 0; i < cnt; i++) { Runnable r = arr[i]; - if (r instanceof TCFDataCache<?> && ((TCFDataCache<?>)r).posted) continue; - r.run(); + if (r instanceof TCFDataCache<?>) { + TCFDataCache<?> c = (TCFDataCache<?>)r; + if (!c.posted && c.waiting_cnt > 0) { + Protocol.invokeLater(c); + c.posted = true; + } + } + else if (r instanceof TCFTask<?>) { + TCFTask<?> t = (TCFTask<?>)r; + if (!t.isDone()) t.run(); + } + else { + r.run(); + } + arr[i] = null; } - if (waiting_list == null) waiting_list = arr; + if (waiting_list == null && arr.length <= WAITING_LIST_SIZE) waiting_list = arr; } } @@ -144,7 +159,7 @@ public abstract class TCFDataCache<V> implements Runnable { assert !disposed; assert !valid; if (cb != null && !isWaiting(cb)) { - if (waiting_list == null) waiting_list = new Runnable[8]; + if (waiting_list == null) waiting_list = new Runnable[WAITING_LIST_SIZE]; if (waiting_cnt >= waiting_list.length) { Runnable[] tmp = new Runnable[waiting_cnt * 2]; System.arraycopy(waiting_list, 0, tmp, 0, waiting_list.length); @@ -160,7 +175,6 @@ public abstract class TCFDataCache<V> implements Runnable { * @return true if 'cb' is in the wait list. */ public boolean isWaiting(Runnable cb) { - if (waiting_list == null) return false; for (int i = 0; i < waiting_cnt; i++) { if (waiting_list[i] == cb) return true; } |