int blockForWriteSpace(int writeLocation) {

        // we want to minimize the number of volatile reads, so we read the writeLocation just once.

        // sets the nextWriteLocation my moving it on by 1, this may cause it it wrap back to the start.
        final int nextWriteLocation = (writeLocation + 1 == capacity) ? 0 : writeLocation + 1;

        if (nextWriteLocation == capacity)

            while (readLocation == 0)
                // // this condition handles the case where writer has caught up with the read,
                // we will wait for a read, ( which will cause a change on the read location )
                blockAtAdd();

        else


            while (nextWriteLocation == readLocation)
                // this condition handles the case general case where the read is at the start of the backing array and we are at the end,
                // blocks as our backing array is full, we will wait for a read, ( which will cause a change on the read location )
                blockAtAdd();

        return nextWriteLocation;
    }
int blockForWriteSpace ( int writeLocation ) { final int nextWriteLocation = ( writeLocation + 1 == capacity ) ? 0 : writeLocation + 1 ; if ( nextWriteLocation == capacity ) while ( readLocation == 0 ) blockAtAdd ( ) ; else while ( nextWriteLocation == readLocation ) blockAtAdd ( ) ; return nextWriteLocation ; }
@param writeLocation the current write location
@return the next write location