More sleep helps !!!

It took me a few seconds this morning to see that there is a lock.wait() in the middle of the awaitXXX method...




Julien Vermillard wrote:
On Fri, 06 Jun 2008 01:59:36 +0200
Emmanuel Lecharny <[EMAIL PROTECTED]> wrote:

Hi guys,

I may be wrong, or tired, but while looking at the DefaultIoFuture
class (trunk), I discovered that the public IoFuture
awaitUninterruptibly() method is using a lock to protect a boolean
flag (ready), which will never change, because the only place where
this flag is modified is also protected by the same lock :

    public IoFuture awaitUninterruptibly() {
        synchronized (lock) {
            while (!ready) {
                waiters++;
                try {
                    lock.wait(DEAD_LOCK_CHECK_INTERVAL);
                } catch (InterruptedException e) {
                } finally {
                    waiters--;
                    if (!ready) {
                        checkDeadLock();
                    }
                }
            }
        }

        return this;
    }


...

    protected void setValue(Object newValue) {
        synchronized (lock) {
            // Allow only once.
            if (ready) {
                return;
            }

            result = newValue;
            ready = true;
            if (waiters > 0) {
                lock.notifyAll();
            }
        }

        notifyListeners();
    }

Do I need extra sleep ???

btw, is the name 'awaitUninterruptibly' sounds correct to any US
native ?

Thanks !


Hi,

As non us native it's sounding just pretty long to type ;)

I would like to precise we accept UK native comments too until it's not
about rugby :)

For the lock I think it's something related to this fancy deadlock
checking, but I understand shit at this code too. I'll need more time
for that I think.

Julien


--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to