View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport;
8   
9   
10  /**
11   * Bypass the regular scheduling mechanism in order to minimize latency and maximize
12   * throughput for transports which have low or no cost for performing a poll operation 
13   * (such as an in-memory queue).
14   */
15  public class ContinuousPollingReceiverWorker extends PollingReceiverWorker
16  {
17      public ContinuousPollingReceiverWorker(AbstractPollingMessageReceiver pollingMessageReceiver)
18      {
19          super(pollingMessageReceiver);
20      }
21  
22      @Override
23      protected void poll() throws Exception
24      {
25          /*
26           * We simply run our own polling loop all the time as long as the receiver is started. The
27           * blocking wait defined by Connector.getQueueTimeout() will prevent this worker's receiver
28           * thread from busy-waiting.
29           */
30          while (getReceiver().isStarted() && !getReceiver().isStopping())
31          {
32              super.poll();
33          }
34      }
35  }