Package org.locationtech.udig.ui

Examples of org.locationtech.udig.ui.WaitCondition


                        public void run() {
                            passed[0] = true;
                        }
                    });

                    PlatformGIS.wait(200, WAIT_LENGTH, new WaitCondition(){

                        public boolean isTrue() {
                            return passed[0] = true;
                        }

                    }, null);

                    assertTrue(passed[0]);
                    states.remove(State.THREAD_HAS_LOCK);
                    lock.unlock();

                    while( !states.contains(State.DISPLAY_HAS_LOCK) )
                        Thread.sleep(200);

                    lockLock.lock();

                    states.add(State.THREAD_WAITING_FOR_LOCK);
                    lock.lock();
                    states.add(State.THREAD_HAS_LOCK);
                    lockLock.unlock();

                    PlatformGIS.wait(200, WAIT_LENGTH, new WaitCondition(){

                        public boolean isTrue() {
                            return passed[0];
                        }

                    }, null);

                    lock.unlock();
                    states.remove(State.THREAD_HAS_LOCK);
                    states.add(State.THREAD_RELEASED_LOCK);
                } catch (Throwable e) {
                    exception[0] = e;
                    displayThread.interrupt();
                }
            }
        };

        Thread t = new Thread(other, "Lock Test Thread"); //$NON-NLS-1$
        t.start();

        // wait til thread has lock
        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return states.contains(State.THREAD_HAS_LOCK);
            }

        }, false);

        lockLock.lock();
        states.add(State.DISPLAY_WAITING_FOR_LOCK);
        lock.lock();
        states.remove(State.DISPLAY_WAITING_FOR_LOCK);
        states.add(State.DISPLAY_HAS_LOCK);
        lockLock.unlock();

        // make sure thread has released lock.
        if (exception[0] != null)
            throw exception[0];
        assertFalse(states.contains(State.THREAD_HAS_LOCK));
        assertTrue(passed[0]);

        passed[0] = false;

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return states.contains(State.THREAD_WAITING_FOR_LOCK);
            }

        }, false);

        if (exception[0] != null)
            throw exception[0];

        states.remove(State.DISPLAY_HAS_LOCK);
        lock.unlock();

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return states.contains(State.THREAD_HAS_LOCK);
            }

        }, false);
        if (exception[0] != null)
            throw exception[0];

        passed[0] = true;

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return states.contains(State.THREAD_RELEASED_LOCK);
            }
View Full Code Here


        Runnable thread1 = new Runnable(){
            public void run() {
                lock.lock();
                gotLock[0] = true;
                try {
                    PlatformGIS.wait(200, WAIT_LENGTH, new WaitCondition(){

                        public boolean isTrue() {
                            return canQuit[0];
                        }

                    }, null);

                    lock.unlock();
                } catch (InterruptedException e) {
                    throw (RuntimeException) new RuntimeException().initCause(e);
                }
            }
        };

        Thread t1 = new Thread(thread1);
        t1.start();

        final boolean[] waiting = new boolean[1];
        waiting[0] = false;

        final boolean[] gotLock2 = new boolean[1];
        gotLock2[0] = false;
        Runnable thread2 = new Runnable(){
            public void run() {
                waiting[0] = true;
                lock.lock();
                gotLock2[0] = true;
            }
        };

        Thread t2 = new Thread(thread2);
        t2.start();

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return gotLock[0];
            }

        }, true);

        canQuit[0] = true;
        lock.lock();

        assertFalse(gotLock2[0]);

        lock.unlock();

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return gotLock2[0];
            }
View Full Code Here

            public void run() {
                result[0]=lock.tryLock();
            }
        }.start();
       
        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return !result[0];
            }
           
View Full Code Here

                    exception[0]=e;
                }
            }
        }.start();
       
        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return ready[0];
            }
           
        }, false);
        if( exception[0]!=null )
            throw exception[0];

        lock.unlock();
       
        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return obtained[0];
            }
           
View Full Code Here

        final Thread current = Thread.currentThread();
        Thread t = new Thread(){
            @Override
            public void run() {
                try {
                    PlatformGIS.wait(100, WAIT_LENGTH, new WaitCondition(){

                        public boolean isTrue() {
                            return !lock.isLocked();
                        }
View Full Code Here

            }
        };

        t.start();

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return lock.getWaitQueueLength(condition) == 1 || ex[0]!=null;
            }

        }, true);
        if( ex[0]!=null )
            throw ex[0];
        assertTrue(lock.hasWaiters(condition));

        lock.lock();
        condition.signal();
        lock.unlock();

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return lock.getWaitQueueLength(condition) == 0;
            }
View Full Code Here

            }
        };

        t.start();

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return isLocked[0];
            }

        }, true);

        t.interrupt();

        UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

            public boolean isTrue() {
                return interrupted[0];
            }
View Full Code Here

                }

            };
            t2.start();

            UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

                public boolean isTrue() {
                    return lock.getWaitQueueLength(condition)==2;
                }
               
            }, false);
            if( exception[0]!=null )
                throw exception[0];
            lock.lock();
            condition.signalAll();
            lock.unlock();
            UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){

                public boolean isTrue() {
                    return lock.getWaitQueueLength(condition)==0;
                }
               
View Full Code Here

            }

        };
        t.start();

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return state.contains(State.THREAD_HAS_LOCK);
            }
           
        }, false);

        lock.lock();

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return done[0];
            }
           
View Full Code Here

        IssueHandler handler = IssueHandler.createHandler(issue);
       
        handler.fixIssue();
        map.sendCommandSync(new BlankCommand());
        UDIGTestUtil.inDisplayThreadWait(10000,new WaitCondition(){

      public boolean isTrue()  { 
                try{

                    ReferencedEnvelope env = new ReferencedEnvelope(features[0].getBounds());
View Full Code Here

TOP

Related Classes of org.locationtech.udig.ui.WaitCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.