a-foundation/src/main/java/com/ajjpj/afoundation/concurrent/LocalQueue.java
void push (Runnable task) {
        final long _base = UNSAFE.getLongVolatile (this, OFFS_BASE); // read base first (and only once)
        final long _top = top;
        if (_top == _base + mask) {
            throw new RejectedExecutionExceptionWithoutStacktrace ("local queue overflow");
        }

        tasks[asArrayindex (_top)] = task;
        // 'top' is only ever modified by the owning thread, so we need no CAS here. Storing 'top' with volatile semantics publishes the task and ensures that changes to the task
        //  can never overtake changes to 'top' wrt visibility.
        UNSAFE.putLongVolatile (this, OFFS_TOP, _top+1);

        // Notify pool only for the first added item per queue.
        if (_top - _base <= 1) {
            pool.onAvailableTask();
        }
    }
void push (Runnable task) {
        final long _base = UNSAFE.getLongVolatile (this, OFFS_BASE); // read base first (and only once)
        final long _top = top;
        if (_top == _base + mask) {
            throw new RejectedExecutionExceptionWithoutStacktrace ("local queue overflow");
        }

        tasks[asArrayindex (_top)] = task;
        // 'top' is only ever modified by the owning thread, so we need no CAS here. Storing 'top' with volatile semantics publishes the task and ensures that changes to the task
        //  can never overtake changes to 'top' wrt visibility.
        UNSAFE.putLongVolatile (this, OFFS_TOP, _top+1);

        // Notify pool only for the first added item per queue.
        if (_top - _base <= 1) {
            pool.onAvailableTask();
        }
    }
void push ( Runnable task ) { final long _base = UNSAFE . getLongVolatile ( this , OFFS_BASE ) ; // read base first (and only once) final long _top = top ; if ( _top == _base + mask ) { throw new RejectedExecutionExceptionWithoutStacktrace ( "local queue overflow" ) ; } tasks [ asArrayindex ( _top ) ] = task ; // 'top' is only ever modified by the owning thread, so we need no CAS here. Storing 'top' with volatile semantics publishes the task and ensures that changes to the task //  can never overtake changes to 'top' wrt visibility. UNSAFE . putLongVolatile ( this , OFFS_TOP , _top + 1 ) ; // Notify pool only for the first added item per queue. if ( _top - _base <= 1 ) { pool . onAvailableTask ( ) ; } }
Add a new task to the top of the localQueue, incrementing 'top'. This is only ever called from the owning thread.
Add a new task to the top of the localQueue incrementing top . This is only ever called from the owning thread .