Java Code Examples for com.sun.corba.se.impl.orbutil.ORBUtility.dprintTrace()

The following are Jave code examples for showing how to use dprintTrace() of the com.sun.corba.se.impl.orbutil.ORBUtility class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: OpenJSharp   File: ReentrantMutex.java   Source Code and License Vote up 6 votes
public synchronized void release()
{
    try {
        if (debug)
            ORBUtility.dprintTrace( this, "release enter: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;

        Thread thr = Thread.currentThread();
        if (thr != holder_)
            throw new INTERNAL(
                "Attempt to release Mutex by thread not holding the Mutex" ) ;
        else
            counter_ -- ;

        if (counter_ == 0) {
            holder_ = null;
            notify();
        }
    } finally {
        if (debug)
            ORBUtility.dprintTrace( this, "release exit: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;
    }
}
 
Example 2
Project: OpenJSharp   File: ReentrantMutex.java   Source Code and License Vote up 6 votes
synchronized int releaseAll()
{
    try {
        if (debug)
            ORBUtility.dprintTrace( this, "releaseAll enter: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;

        Thread thr = Thread.currentThread();
        if (thr != holder_)
            throw new INTERNAL(
                "Attempt to releaseAll Mutex by thread not holding the Mutex" ) ;

        int result = counter_ ;
        counter_ = 0 ;
        holder_ = null ;
        notify() ;
        return result ;
    } finally {
        if (debug)
            ORBUtility.dprintTrace( this, "releaseAll exit: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;
    }
}
 
Example 3
Project: openjdk-jdk10   File: ReentrantMutex.java   Source Code and License Vote up 6 votes
public synchronized void release()
{
    try {
        if (debug)
            ORBUtility.dprintTrace( this, "release enter: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;

        Thread thr = Thread.currentThread();
        if (thr != holder_)
            throw new INTERNAL(
                "Attempt to release Mutex by thread not holding the Mutex" ) ;
        else
            counter_ -- ;

        if (counter_ == 0) {
            holder_ = null;
            notify();
        }
    } finally {
        if (debug)
            ORBUtility.dprintTrace( this, "release exit: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;
    }
}
 
Example 4
Project: openjdk-jdk10   File: ReentrantMutex.java   Source Code and License Vote up 6 votes
synchronized int releaseAll()
{
    try {
        if (debug)
            ORBUtility.dprintTrace( this, "releaseAll enter: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;

        Thread thr = Thread.currentThread();
        if (thr != holder_)
            throw new INTERNAL(
                "Attempt to releaseAll Mutex by thread not holding the Mutex" ) ;

        int result = counter_ ;
        counter_ = 0 ;
        holder_ = null ;
        notify() ;
        return result ;
    } finally {
        if (debug)
            ORBUtility.dprintTrace( this, "releaseAll exit: " +
                " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;
    }
}
 
Example 5
Project: OpenJSharp   File: ReentrantMutex.java   Source Code and License Vote up 5 votes
public void acquire() throws InterruptedException {
    if (Thread.interrupted())
        throw new InterruptedException();

    synchronized(this) {
        try {
            if (debug)
                ORBUtility.dprintTrace( this,
                    "acquire enter: holder_=" +
                    ORBUtility.getThreadName(holder_) +
                    " counter_=" + counter_ ) ;

            Thread thr = Thread.currentThread();
            if (holder_ != thr) {
                try {
                    while (counter_ > 0)
                        wait();

                    // This can't happen, but make sure anyway
                    if (counter_ != 0)
                        throw new INTERNAL(
                            "counter not 0 when first acquiring mutex" ) ;

                    holder_ = thr;
                } catch (InterruptedException ex) {
                    notify();
                    throw ex;
                }
            }

            counter_ ++ ;
        } finally {
            if (debug)
                ORBUtility.dprintTrace( this, "acquire exit: holder_=" +
                ORBUtility.getThreadName(holder_) + " counter_=" +
                counter_ ) ;
        }
    }
}
 
Example 6
Project: openjdk-jdk10   File: ReentrantMutex.java   Source Code and License Vote up 5 votes
public void acquire() throws InterruptedException {
    if (Thread.interrupted())
        throw new InterruptedException();

    synchronized(this) {
        try {
            if (debug)
                ORBUtility.dprintTrace( this,
                    "acquire enter: holder_=" +
                    ORBUtility.getThreadName(holder_) +
                    " counter_=" + counter_ ) ;

            Thread thr = Thread.currentThread();
            if (holder_ != thr) {
                try {
                    while (counter_ > 0)
                        wait();

                    // This can't happen, but make sure anyway
                    if (counter_ != 0)
                        throw new INTERNAL(
                            "counter not 0 when first acquiring mutex" ) ;

                    holder_ = thr;
                } catch (InterruptedException ex) {
                    notify();
                    throw ex;
                }
            }

            counter_ ++ ;
        } finally {
            if (debug)
                ORBUtility.dprintTrace( this, "acquire exit: holder_=" +
                ORBUtility.getThreadName(holder_) + " counter_=" +
                counter_ ) ;
        }
    }
}
 
Example 7
Project: OpenJSharp   File: ReentrantMutex.java   Source Code and License Vote up 4 votes
void acquireAll( int count ) throws InterruptedException
{
    if (Thread.interrupted())
        throw new InterruptedException();

    synchronized(this) {
        try {
            if (debug)
                ORBUtility.dprintTrace( this,
                    "acquireAll enter: count=" + count + " holder_=" +
                    ORBUtility.getThreadName(holder_) + " counter_=" +
                    counter_ ) ;
            Thread thr = Thread.currentThread();
            if (holder_ == thr) {
                throw new INTERNAL(
                    "Cannot acquireAll while holding the mutex" ) ;
            } else {
                try {
                    while (counter_ > 0)
                        wait();

                    // This can't happen, but make sure anyway
                    if (counter_ != 0)
                        throw new INTERNAL(
                            "counter not 0 when first acquiring mutex" ) ;

                    holder_ = thr;
                } catch (InterruptedException ex) {
                    notify();
                    throw ex;
                }
            }

            counter_ = count ;
        } finally {
            if (debug)
                ORBUtility.dprintTrace( this, "acquireAll exit: count=" +
                count + " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;
        }
    }
}
 
Example 8
Project: OpenJSharp   File: ReentrantMutex.java   Source Code and License Vote up 4 votes
public boolean attempt(long msecs) throws InterruptedException {
    if (Thread.interrupted())
        throw new InterruptedException();

    synchronized(this) {
        try {
            if (debug)
                ORBUtility.dprintTrace( this, "attempt enter: msecs=" +
                    msecs + " holder_=" +
                    ORBUtility.getThreadName(holder_) +
                    " counter_=" + counter_ ) ;

            Thread thr = Thread.currentThread() ;

            if (counter_==0) {
                holder_ = thr;
                counter_ = 1 ;
                return true;
            } else if (msecs <= 0) {
                return false;
            } else {
                long waitTime = msecs;
                long start = System.currentTimeMillis();
                try {
                    for (;;) {
                        wait(waitTime);
                        if (counter_==0) {
                            holder_ = thr;
                            counter_ = 1 ;
                            return true;
                        } else {
                            waitTime = msecs -
                                (System.currentTimeMillis() - start);

                            if (waitTime <= 0)
                                return false;
                        }
                    }
                } catch (InterruptedException ex) {
                    notify();
                    throw ex;
                }
            }
        } finally {
            if (debug)
                ORBUtility.dprintTrace( this, "attempt exit: " +
                    " holder_=" + ORBUtility.getThreadName(holder_) +
                    " counter_=" + counter_ ) ;
        }
    }
}
 
Example 9
Project: openjdk-jdk10   File: ReentrantMutex.java   Source Code and License Vote up 4 votes
void acquireAll( int count ) throws InterruptedException
{
    if (Thread.interrupted())
        throw new InterruptedException();

    synchronized(this) {
        try {
            if (debug)
                ORBUtility.dprintTrace( this,
                    "acquireAll enter: count=" + count + " holder_=" +
                    ORBUtility.getThreadName(holder_) + " counter_=" +
                    counter_ ) ;
            Thread thr = Thread.currentThread();
            if (holder_ == thr) {
                throw new INTERNAL(
                    "Cannot acquireAll while holding the mutex" ) ;
            } else {
                try {
                    while (counter_ > 0)
                        wait();

                    // This can't happen, but make sure anyway
                    if (counter_ != 0)
                        throw new INTERNAL(
                            "counter not 0 when first acquiring mutex" ) ;

                    holder_ = thr;
                } catch (InterruptedException ex) {
                    notify();
                    throw ex;
                }
            }

            counter_ = count ;
        } finally {
            if (debug)
                ORBUtility.dprintTrace( this, "acquireAll exit: count=" +
                count + " holder_=" + ORBUtility.getThreadName(holder_) +
                " counter_=" + counter_ ) ;
        }
    }
}
 
Example 10
Project: openjdk-jdk10   File: ReentrantMutex.java   Source Code and License Vote up 4 votes
public boolean attempt(long msecs) throws InterruptedException {
    if (Thread.interrupted())
        throw new InterruptedException();

    synchronized(this) {
        try {
            if (debug)
                ORBUtility.dprintTrace( this, "attempt enter: msecs=" +
                    msecs + " holder_=" +
                    ORBUtility.getThreadName(holder_) +
                    " counter_=" + counter_ ) ;

            Thread thr = Thread.currentThread() ;

            if (counter_==0) {
                holder_ = thr;
                counter_ = 1 ;
                return true;
            } else if (msecs <= 0) {
                return false;
            } else {
                long waitTime = msecs;
                long start = System.currentTimeMillis();
                try {
                    for (;;) {
                        wait(waitTime);
                        if (counter_==0) {
                            holder_ = thr;
                            counter_ = 1 ;
                            return true;
                        } else {
                            waitTime = msecs -
                                (System.currentTimeMillis() - start);

                            if (waitTime <= 0)
                                return false;
                        }
                    }
                } catch (InterruptedException ex) {
                    notify();
                    throw ex;
                }
            }
        } finally {
            if (debug)
                ORBUtility.dprintTrace( this, "attempt exit: " +
                    " holder_=" + ORBUtility.getThreadName(holder_) +
                    " counter_=" + counter_ ) ;
        }
    }
}