public void run()

in core/src/main/java/com/epam/cme/mdp3/core/channel/MdpFeedWorker.java [124:164]


    public void run() {
        /*
         * if any thread in result of concurrency created a new the same feed thread instance too early, and
         * previous feed thread shutdown still active, then wait until full shutdown
         */
        while (isShutdown()) {
            LockSupport.parkNanos(TimeUnit.MICROSECONDS.toNanos(1));
        }
        // if impossible to switch from stopped state to active, then we should not continue (concurrently illegal state)
        if (!isRunnable()) {
            return;
        }
        try {
            open();
        } catch (Exception e) {
            logger.error("Failed to open Feed", e);
            return;
        }
        notifyStarted();
        final MdpPacket mdpPacket = MdpPacket.instance();
        final ByteBuffer byteBuffer = ByteBuffer.allocateDirect(SbeConstants.MDP_PACKET_MAX_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        mdpPacket.wrapFromBuffer(byteBuffer);
        // work while any thread really started shutdown and did not cancel it in time
        while (!this.feedState.compareAndSet(PENDING_SHUTDOWN, SHUTDOWN)) {
            try {
                select(byteBuffer, mdpPacket);
            } catch (Exception e) {
                logger.error("Exception in message loop", e);
            }
        }
        try {
            close();
            mdpPacket.release();
            notifyStopped();
            // finally stop the feed thread. If exists another feed thread in wait state, then it will proceed from this moment
            this.feedState.compareAndSet(SHUTDOWN, STOPPED);
        } catch (IOException e) {
            logger.error("Failed to stop Feed", e);
        }
        logger.debug("Stop message loop in {}", cfg.toString());
    }