/** * Determines if a particular entry has been published. * * @param sequence The sequence to identify the entry. * @return If the value has been published or not. */ public boolean isPublished(long sequence) { return sequencer.isAvailable(sequence); }
/** * Determines if a particular entry is available. Note that using this when not within a context that is * maintaining a sequence barrier, it is likely that using this to determine if you can read a value is likely * to result in a race condition and broken code. * * @param sequence The sequence to identify the entry. * @return If the value can be read or not. * @deprecated Please don't use this method. It probably won't * do what you think that it does. */ @Deprecated public boolean isPublished(long sequence) { return sequencer.isAvailable(sequence); }
@Test public void shouldOnlyAllowMessagesToBeAvailableIfSpecificallyPublished() throws Exception { publisher.publish(3); publisher.publish(5); assertThat(publisher.isAvailable(0), is(false)); assertThat(publisher.isAvailable(1), is(false)); assertThat(publisher.isAvailable(2), is(false)); assertThat(publisher.isAvailable(3), is(true)); assertThat(publisher.isAvailable(4), is(false)); assertThat(publisher.isAvailable(5), is(true)); assertThat(publisher.isAvailable(6), is(false)); } }
@Test public void shouldNotBeAvailableUntilPublished() throws Exception { long next = sequencer.next(6); for (int i = 0; i <= 5; i++) { assertThat(sequencer.isAvailable(i), is(false)); } sequencer.publish(next - (6 - 1), next); for (int i = 0; i <= 5; i++) { assertThat(sequencer.isAvailable(i), is(true)); } assertThat(sequencer.isAvailable(6), is(false)); }
/** * Determines if a particular entry is available. Note that using this when not within a context that is * maintaining a sequence barrier, it is likely that using this to determine if you can read a value is likely * to result in a race condition and broken code. * * @param sequence The sequence to identify the entry. * @return If the value can be read or not. * @deprecated Please don't use this method. It probably won't * do what you think that it does. */ @Deprecated public boolean isPublished(long sequence) { return sequencer.isAvailable(sequence); }
/** * Determines if a particular entry has been published. * * @param sequence The sequence to identify the entry. * @return If the value has been published or not. */ public boolean isPublished(long sequence) { return sequencer.isAvailable(sequence); }
/** * Determines if a particular entry has been published. * * @param sequence The sequence to identify the entry. * @return If the value has been published or not. */ public boolean isPublished(long sequence) { return sequencer.isAvailable(sequence); }
/** * Determines if a particular entry is available. Note that using this when not within a context that is * maintaining a sequence barrier, it is likely that using this to determine if you can read a value is likely * to result in a race condition and broken code. * * @param sequence The sequence to identify the entry. * @return If the value can be read or not. * @deprecated Please don't use this method. It probably won't * do what you think that it does. */ @Deprecated public boolean isPublished(long sequence) { return sequencer.isAvailable(sequence); }