comparison dwtx/jface/viewers/deferred/BackgroundContentProvider.d @ 167:862b05e0334a

Add a wrapper for Thread
author Frank Benoit <benoit@tionex.de>
date Tue, 09 Sep 2008 15:59:16 +0200
parents ea8ff534f622
children c3583c6ec027
comparison
equal deleted inserted replaced
163:e5dd0081ccba 167:862b05e0334a
27 27
28 import dwtx.jface.viewers.AcceptAllFilter; 28 import dwtx.jface.viewers.AcceptAllFilter;
29 import dwtx.jface.viewers.IFilter; 29 import dwtx.jface.viewers.IFilter;
30 30
31 import dwt.dwthelper.utils; 31 import dwt.dwthelper.utils;
32 import tango.core.Thread; 32 import dwtx.dwtxhelper.JThread;
33 33
34 /** 34 /**
35 * Contains the algorithm for performing background sorting and filtering in a virtual 35 * Contains the algorithm for performing background sorting and filtering in a virtual
36 * table. This is the real implementation for <code>DeferredContentProvider</code>. 36 * table. This is the real implementation for <code>DeferredContentProvider</code>.
37 * However, this class will work with anything that implements <code>AbstractVirtualTable</code> 37 * However, this class will work with anything that implements <code>AbstractVirtualTable</code>
139 * sortMutex when accessing. 139 * sortMutex when accessing.
140 */ 140 */
141 private ConcurrentTableUpdator updator; 141 private ConcurrentTableUpdator updator;
142 142
143 private IProgressMonitor sortingProgressMonitor; 143 private IProgressMonitor sortingProgressMonitor;
144 private Thread sortThread = null; 144 private JThread sortThread = null;
145 145
146 private /+volatile+/ FastProgressReporter sortMon; 146 private /+volatile+/ FastProgressReporter sortMon;
147 147
148 private /+volatile+/ ConcurrentTableUpdator.Range range; 148 private /+volatile+/ ConcurrentTableUpdator.Range range;
149 149
473 /** 473 /**
474 * true if we need to sort 474 * true if we need to sort
475 */ 475 */
476 private bool sortScheduled = false; 476 private bool sortScheduled = false;
477 477
478 private final class SortThread : Thread { 478 private final class SortThread : JThread {
479 private this(String name) { 479 private this(String name) {
480 super(/+name+/); 480 super(name);
481 } 481 }
482 482
483 public /+override+/ void run() { 483 public override void run() {
484 loop: while (true) { 484 loop: while (true) {
485 synchronized (lock) { 485 synchronized (lock) {
486 sortScheduled = false; 486 sortScheduled = false;
487 } 487 }
488 try { 488 try {
512 // request sorting 512 // request sorting
513 sortScheduled = true; 513 sortScheduled = true;
514 if (!sortThreadStarted) { 514 if (!sortThreadStarted) {
515 sortThreadStarted = true; 515 sortThreadStarted = true;
516 sortThread = new SortThread(SORTING); 516 sortThread = new SortThread(SORTING);
517 sortThread.isDaemon = true; 517 sortThread.setDaemon( true );
518 sortThread.priority = sortThread.priority - 1; 518 sortThread.setPriority( sortThread.getPriority() - 1 );
519 sortThread.start(); 519 sortThread.start();
520 } 520 }
521 } 521 }
522 } 522 }
523 523