Skip to content

1.x: enable TestScheduler with nanosecond periodic scheduling#4884

Merged
akarnokd merged 1 commit intoReactiveX:1.xfrom
akarnokd:TestSchedulerNanos
Nov 28, 2016
Merged

1.x: enable TestScheduler with nanosecond periodic scheduling#4884
akarnokd merged 1 commit intoReactiveX:1.xfrom
akarnokd:TestSchedulerNanos

Conversation

@akarnokd
Copy link
Member

The default periodic scheduling code accessed the current worker time as milliseconds which prevents running microsecond and nanosecond scale unit tests with TestScheduler as its internal nanosecond resolution time is always converted, losing precision.

This PR introduces the internal SchedulePeriodicHelper class, moves the default scheduling code into a static method and defines a NowNanoSupplier interface that is now implemented by TestSchedulerWorker to return the current nano time. The default Worker.schedulePeriodically delegates to this static method and given a null noNanoSupplier the Worker.now() is converted to nanoseconds as usual.

Related: #4883

@akarnokd akarnokd added this to the 1.3 milestone Nov 25, 2016
@codecov-io
Copy link

codecov-io commented Nov 25, 2016

Current coverage is 84.21% (diff: 93.10%)

Merging #4884 into 1.x will decrease coverage by 0.04%

@@                1.x      #4884   diff @@
==========================================
  Files           287        288     +1   
  Lines         17803      17808     +5   
  Methods           0          0          
  Messages          0          0          
  Branches       2696       2698     +2   
==========================================
- Hits          15000      14997     -3   
- Misses         1952       1960     +8   
  Partials        851        851          

Powered by Codecov. Last update 8fff67d...0c98869


@Test
public void resolution() {
for (final TimeUnit unit : TimeUnit.values()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@akarnokd akarnokd merged commit a606a26 into ReactiveX:1.x Nov 28, 2016
@akarnokd akarnokd deleted the TestSchedulerNanos branch November 28, 2016 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants