File tree Expand file tree Collapse file tree
Tests/DistributedClusterTests/Cluster/SWIM Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -484,18 +484,21 @@ final class SWIMActorClusteredTests: ClusteredActorSystemsXCTestCase {
484484}
485485
486486class TestTimeSource {
487- let currentTime : UnsafeAtomic < UInt64 >
487+ private var instant : ContinuousClock . Instant
488488
489- /// starting from 1 to ensure .distantPast is already expired
490- init ( currentTime: UInt64 = 1 ) {
491- self . currentTime = . create ( currentTime)
489+ /// starting from a value close to the distant past
490+ init ( currentTime: ContinuousClock . Instant = ( . now - . nanoseconds ( 1 ) ) ) {
491+ self . instant = currentTime
492492 }
493493
494- func now( ) -> DispatchTime {
495- DispatchTime ( uptimeNanoseconds: self . currentTime. load ( ordering: . relaxed) )
494+ /// Returns the current mocked time as ContinuousClock.Instant
495+ @Sendable
496+ func now( ) -> ContinuousClock . Instant {
497+ self . instant
496498 }
497499
498- func tick( ) {
499- _ = self . currentTime. loadThenWrappingIncrement ( by: 100 , ordering: . relaxed)
500+ /// Advances the mocked time by the specified duration (default 100 nanoseconds, for compatibility)
501+ func tick( by duration: Duration = . nanoseconds( 100 ) ) {
502+ self . instant += duration
500503 }
501504}
You can’t perform that action at this time.
0 commit comments