comparison dwtx/jface/text/reconciler/AbstractReconciler.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents 25f1f92fa3df
children 862b05e0334a
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
87 * @param name the thread's name 87 * @param name the thread's name
88 */ 88 */
89 public this(String name) { 89 public this(String name) {
90 thread = new Thread( &run ); 90 thread = new Thread( &run );
91 thread.name = name; 91 thread.name = name;
92 thread.priority = Thread.MIN_PRIORITY; 92 thread.priority = Thread.PRIORITY_MIN;
93 thread.isDaemon(true); 93 thread.isDaemon(true);
94 } 94 }
95 95
96 public void start(){ 96 public void start(){
97 thread.start(); 97 thread.start();
98 } 98 }
99 99 public bool isAlive(){
100 return thread.isRunning();
101 }
102 public Thread getThread(){
103 return thread;
104 }
100 /** 105 /**
101 * Returns whether a reconciling strategy is active right now. 106 * Returns whether a reconciling strategy is active right now.
102 * 107 *
103 * @return <code>true</code> if a activity is active 108 * @return <code>true</code> if a activity is active
104 */ 109 */
258 * @see IDocumentListener#documentChanged(DocumentEvent) 263 * @see IDocumentListener#documentChanged(DocumentEvent)
259 */ 264 */
260 public void documentChanged(DocumentEvent e) { 265 public void documentChanged(DocumentEvent e) {
261 266
262 if (!fThread.isDirty() && fThread.isAlive()) { 267 if (!fThread.isDirty() && fThread.isAlive()) {
263 if (!fIsAllowedToModifyDocument && Thread.currentThread() is fThread) 268 if (!fIsAllowedToModifyDocument && Thread.getThis() is fThread.getThread())
264 throw new UnsupportedOperationException("The reconciler thread is not allowed to modify the document"); //$NON-NLS-1$ 269 throw new UnsupportedOperationException("The reconciler thread is not allowed to modify the document"); //$NON-NLS-1$
265 aboutToBeReconciled(); 270 aboutToBeReconciled();
266 } 271 }
267 272
268 /* 273 /*
472 /* 477 /*
473 * @see IReconciler#install(ITextViewer) 478 * @see IReconciler#install(ITextViewer)
474 */ 479 */
475 public void install(ITextViewer textViewer) { 480 public void install(ITextViewer textViewer) {
476 481
477 Assert.isNotNull(textViewer); 482 Assert.isNotNull(cast(Object)textViewer);
478 fViewer= textViewer; 483 fViewer= textViewer;
479 484
480 synchronized (this) { 485 synchronized (this) {
481 if (fThread !is null) 486 if (fThread !is null)
482 return; 487 return;
483 fThread= new BackgroundThread(getClass().getName()); 488 fThread= new BackgroundThread(this.classinfo.name);
484 } 489 }
485 490
486 fDirtyRegionQueue= new DirtyRegionQueue(); 491 fDirtyRegionQueue= new DirtyRegionQueue();
487 492
488 fListener= new Listener(); 493 fListener= new Listener();
595 protected synchronized void startReconciling() { 600 protected synchronized void startReconciling() {
596 if (fThread is null) 601 if (fThread is null)
597 return; 602 return;
598 603
599 if (!fThread.isAlive()) { 604 if (!fThread.isAlive()) {
600 try { 605 // DWT
606 // try {
601 fThread.start(); 607 fThread.start();
602 } catch (IllegalThreadStateException e) { 608 // } catch (IllegalThreadStateException e) {
603 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=40549 609 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=40549
604 // This is the only instance where the thread is started; since 610 // This is the only instance where the thread is started; since
605 // we checked that it is not alive, it must be dead already due 611 // we checked that it is not alive, it must be dead already due
606 // to a run-time exception or error. Exit. 612 // to a run-time exception or error. Exit.
607 } 613 // }
608 } else { 614 } else {
609 fThread.reset(); 615 fThread.reset();
610 } 616 }
611 } 617 }
612 618
622 * 628 *
623 * @return <code>true</code> if running in this reconciler's background thread 629 * @return <code>true</code> if running in this reconciler's background thread
624 * @since 3.4 630 * @since 3.4
625 */ 631 */
626 protected bool isRunningInReconcilerThread() { 632 protected bool isRunningInReconcilerThread() {
627 return Thread.currentThread() is fThread; 633 return Thread.getThis() is fThread.getThread();
628 } 634 }
629 } 635 }