Package org.vmmagic.unboxed

Examples of org.vmmagic.unboxed.Address.attempt()


        } else {
            final Address ownerAddr = ObjectReference.fromObject(this)
                .toAddress();
            final ObjectReference procRef = ObjectReference.fromObject(VmMagic
                .currentProcessor());
            while (!ownerAddr.attempt(null, procRef)) {
                // Busy wait
            }
            // Now I'm the owner
            lockCount = lockCount.add(Word.one());
        }
View Full Code Here


        final Address lcAddr = getLCAddress();
        while (loop) {
            // Get current thread
            final VmThread current = VmMagic.currentProcessor().getCurrentThread();
            // Try to claim this monitor
            if (lcAddr.attempt(0, 1)) {
                loop = false;
                dropFromOwner();
                this.owner = current;
                addToOwner();
            } else {
View Full Code Here

     */
    @Inline
    private final void lock() {
        //final VmProcessor proc = VmProcessor.current();
        final Address mlAddr = ObjectReference.fromObject(this).toAddress().add(4);
        while (!mlAddr.attempt(0, 1)) {
            //proc.yield(true); // Yield breaks the Uninterruptible idea, so don't use it!
        }
    }

    /**
 
View Full Code Here

     * @see #monitorLock
     */
    @Inline
    private final boolean lockNoWait() {
        final Address mlAddr = ObjectReference.fromObject(this).toAddress().add(4);
        return mlAddr.attempt(0, 1);
    }

    /**
     * Release access to this monitor. A monitor may only be locked for a small
     * amount of time, since this method uses a spinlock.
View Full Code Here

            Unsafe.die("Deadlock in SpinLock#lock");
        }

        // Do the spinlock
        final Address mlAddr = ObjectReference.fromObject(this).toAddress();
        while (!mlAddr.attempt(0, 1)) {
            current.yield(true);
        }
        this.owner = current;
    }
View Full Code Here

        for (;;) {
            // attempt fast path: object is not locked.
            final Word oldlockword = statusPtr.prepareWord();

            final Word statusFlags = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.STATUS_FLAGS_MASK));
            if (statusPtr.attempt(statusFlags, statusFlags.or(tid))) {
                // fast path succeeded, the object was not locked and
                // has been locked by the current thread.
                return;
            }
View Full Code Here

                    final Word newlockword;
                    newlockword = oldlockword.add(Word.fromIntZeroExtend(ObjectFlags.LOCK_COUNT_INC));
                    // Try to update lock, it may be inflated by some other
                    // thread, so
                    // be cautious
                    if (statusPtr.attempt(oldlockword, newlockword)) {
                        return;
                    }
                }
            } else {
                // Another thread owns the lock
View Full Code Here

                    newlockword = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.STATUS_FLAGS_MASK));
                } else {
                    // count is non-zero, decrement count
                    newlockword = oldlockword.sub(Word.fromIntSignExtend(ObjectFlags.LOCK_COUNT_INC));
                }
                if (statusPtr.attempt(oldlockword, newlockword)) {
                    return;
                }
            } else {
                // lock not owned by us!
                String exMsg = "Lock not owned by us:";
View Full Code Here

            }
            m.initialize(thread, lockcount);

            final Word statusFlags = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.STATUS_FLAGS_MASK));
            final Word newlockword = monAddr.or(statusFlags).or(Word.fromIntZeroExtend(ObjectFlags.LOCK_EXPANDED));
            if (statusPtr.attempt(oldlockword, newlockword)) {
                // successfully obtained inflated lock.
                return m;
            }
        }
    }
View Full Code Here

                return false;
            }
            Word newValue = oldValue.and(
                Word.fromIntZeroExtend(ObjectFlags.GC_COLOUR_MASK).not())
                .or(Word.fromIntZeroExtend(newColor));
            if (addr.attempt(oldValue, newValue)) {
                return true;
            }
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.