gpt4 book ai didi

org.agrona.concurrent.YieldingIdleStrategy类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 04:00:49 25 4
gpt4 key购买 nike

本文整理了Java中org.agrona.concurrent.YieldingIdleStrategy类的一些代码示例,展示了YieldingIdleStrategy类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YieldingIdleStrategy类的具体详情如下:
包路径:org.agrona.concurrent.YieldingIdleStrategy
类名称:YieldingIdleStrategy

YieldingIdleStrategy介绍

[英]IdleStrategy that will call Thread#yield() when the work count is zero.
[中]IdleStrategy,在工作计数为零时调用线程#yield()。

代码示例

代码示例来源:origin: real-logic/aeron

/**
 * Create a proxy with a {@link Publication} for sending control message requests.
 * <p>
 * This provides a default {@link IdleStrategy} of a {@link YieldingIdleStrategy} when offers are back pressured
 * with a defaults of {@link AeronArchive.Configuration#MESSAGE_TIMEOUT_DEFAULT_NS} and
 * {@link #DEFAULT_RETRY_ATTEMPTS}.
 *
 * @param publication publication for sending control messages to an archive.
 */
public ArchiveProxy(final Publication publication)
{
  this(
    publication,
    new YieldingIdleStrategy(),
    new SystemNanoClock(),
    MESSAGE_TIMEOUT_DEFAULT_NS,
    DEFAULT_RETRY_ATTEMPTS);
}

代码示例来源:origin: real-logic/aeron

.termBufferSparseFile(true)
.threadingMode(threadingMode)
.sharedIdleStrategy(new YieldingIdleStrategy())
.spiesSimulateConnection(true)
.errorHandler(Throwable::printStackTrace)

代码示例来源:origin: io.aeron/aeron-all

/**
 * Create a proxy with a {@link Publication} for sending control message requests.
 * <p>
 * This provides a default {@link IdleStrategy} of a {@link YieldingIdleStrategy} when offers are back pressured
 * with a defaults of {@link AeronArchive.Configuration#MESSAGE_TIMEOUT_DEFAULT_NS} and
 * {@link #DEFAULT_RETRY_ATTEMPTS}.
 *
 * @param publication publication for sending control messages to an archive.
 */
public ArchiveProxy(final Publication publication)
{
  this(
    publication,
    new YieldingIdleStrategy(),
    new SystemNanoClock(),
    MESSAGE_TIMEOUT_DEFAULT_NS,
    DEFAULT_RETRY_ATTEMPTS);
}

代码示例来源:origin: real-logic/artio

public static void main(final String[] args)
  {
    final LibraryConfiguration libraryConfiguration = new LibraryConfiguration()
      .libraryAeronChannels(singletonList(SoleEngine.AERON_CHANNEL))
      .libraryIdleStrategy(new YieldingIdleStrategy());

    libraryConfiguration.replyTimeoutInMs(1000);

    try (FixLibrary library = SampleUtil.blockingConnect(libraryConfiguration))
    {
      System.out.println("Connected");

      while (library.isConnected())
      {
        library.poll(1);

        Thread.yield();
      }
    }
  }
}

代码示例来源:origin: real-logic/artio

@Before
public void setUp()
{
  mediaDriver = TestFixtures.launchMediaDriver();
  aeronArchive = AeronArchive.connect();
  recordingIdLookup = new RecordingIdLookup(new YieldingIdleStrategy(), aeron().countersReader());
  aeronArchive.startRecording(CHANNEL, STREAM_ID, SourceLocation.LOCAL);
  final Aeron aeron = aeron();
  publication = aeron.addExclusivePublication(CHANNEL, STREAM_ID);
  subscription = aeron.addSubscription(CHANNEL, STREAM_ID);
  final File logFile = logFile(SESSION_ID);
  IoUtil.deleteIfExists(logFile);
  newReplayIndex();
  query = new ReplayQuery(
    DEFAULT_LOG_FILE_DIR,
    DEFAULT_LOGGER_CACHE_NUM_SETS,
    DEFAULT_LOGGER_CACHE_SET_SIZE,
    existingBufferFactory,
    DEFAULT_OUTBOUND_LIBRARY_STREAM,
    new NoOpIdleStrategy(),
    aeronArchive,
    errorHandler,
    DEFAULT_ARCHIVE_REPLAY_STREAM);
  returnBuffer(indexBuffer, SESSION_ID);
  returnBuffer(ByteBuffer.allocate(16 * 1024), SESSION_ID_2);
  when(newBufferFactory.map(any(), anyInt())).thenReturn(indexBuffer);
}

代码示例来源:origin: real-logic/artio

public static MediaDriver.Context mediaDriverContext(final int termBufferLength, final boolean dirsDeleteOnStart)
{
  return new MediaDriver.Context()
    .useWindowsHighResTimer(true)
    .threadingMode(SHARED)
    .sharedIdleStrategy(new YieldingIdleStrategy())
    .dirDeleteOnStart(dirsDeleteOnStart)
    .warnIfDirectoryExists(false)
    .publicationTermBufferLength(termBufferLength)
    .ipcTermBufferLength(termBufferLength);
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com