-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,844 additions
and
1,952 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,36 @@ | ||
namespace R3 | ||
namespace R3; | ||
|
||
public static partial class Event | ||
{ | ||
public static partial class Event | ||
public static Event<TMessage, Unit> Empty<TMessage>() | ||
{ | ||
public static Event<TMessage, Unit> Empty<TMessage>() | ||
{ | ||
return R3.Factories.Empty<TMessage>.Instance; | ||
} | ||
return R3.Empty<TMessage>.Instance; | ||
} | ||
|
||
public static Event<TMessage, Unit> Empty<TMessage>(TimeProvider timeProvider) | ||
{ | ||
return ReturnOnCompleted<TMessage, Unit>(default, timeProvider); | ||
} | ||
public static Event<TMessage, Unit> Empty<TMessage>(TimeProvider timeProvider) | ||
{ | ||
return ReturnOnCompleted<TMessage, Unit>(default, timeProvider); | ||
} | ||
|
||
public static Event<TMessage, Unit> Empty<TMessage>(TimeSpan dueTime, TimeProvider timeProvider) | ||
{ | ||
return ReturnOnCompleted<TMessage, Unit>(default, dueTime, timeProvider); | ||
} | ||
public static Event<TMessage, Unit> Empty<TMessage>(TimeSpan dueTime, TimeProvider timeProvider) | ||
{ | ||
return ReturnOnCompleted<TMessage, Unit>(default, dueTime, timeProvider); | ||
} | ||
} | ||
|
||
namespace R3.Factories | ||
internal sealed class Empty<TMessage> : Event<TMessage, Unit> | ||
{ | ||
internal sealed class Empty<TMessage> : Event<TMessage, Unit> | ||
{ | ||
// singleton | ||
public static readonly Empty<TMessage> Instance = new Empty<TMessage>(); | ||
// singleton | ||
public static readonly Empty<TMessage> Instance = new Empty<TMessage>(); | ||
|
||
protected override IDisposable SubscribeCore(Subscriber<TMessage, Unit> subscriber) | ||
{ | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
} | ||
protected override IDisposable SubscribeCore(Subscriber<TMessage, Unit> subscriber) | ||
{ | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
} | ||
|
||
Empty() | ||
{ | ||
Empty() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
namespace R3 | ||
namespace R3; | ||
|
||
public static partial class Event | ||
{ | ||
public static partial class Event | ||
// Never | ||
public static Event<TMessage, TComplete> Never<TMessage, TComplete>() | ||
{ | ||
// Never | ||
public static Event<TMessage, TComplete> Never<TMessage, TComplete>() | ||
{ | ||
return R3.Factories.Never<TMessage, TComplete>.Instance; | ||
} | ||
return R3.Never<TMessage, TComplete>.Instance; | ||
} | ||
} | ||
|
||
namespace R3.Factories | ||
internal sealed class Never<TMessage, TComplete> : Event<TMessage, TComplete> | ||
{ | ||
internal sealed class Never<TMessage, TComplete> : Event<TMessage, TComplete> | ||
{ | ||
// singleton | ||
public static readonly Never<TMessage, TComplete> Instance = new Never<TMessage, TComplete>(); | ||
// singleton | ||
public static readonly Never<TMessage, TComplete> Instance = new Never<TMessage, TComplete>(); | ||
|
||
Never() | ||
{ | ||
Never() | ||
{ | ||
|
||
} | ||
} | ||
|
||
protected override IDisposable SubscribeCore(Subscriber<TMessage, TComplete> subscriber) | ||
{ | ||
return Disposable.Empty; | ||
} | ||
protected override IDisposable SubscribeCore(Subscriber<TMessage, TComplete> subscriber) | ||
{ | ||
return Disposable.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,68 @@ | ||
namespace R3 | ||
namespace R3; | ||
|
||
public static partial class Event | ||
{ | ||
public static partial class Event | ||
// no scheduler(TimeProvider) overload | ||
|
||
public static Event<int, Unit> Range(int start, int count) | ||
{ | ||
// no scheduler(TimeProvider) overload | ||
long max = ((long)start) + count - 1; | ||
if (count < 0 || max > int.MaxValue) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
|
||
public static Event<int, Unit> Range(int start, int count) | ||
if (count == 0) | ||
{ | ||
long max = ((long)start) + count - 1; | ||
if (count < 0 || max > int.MaxValue) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
return Empty<int>(); | ||
} | ||
|
||
if (count == 0) | ||
{ | ||
return Empty<int>(); | ||
} | ||
return new Range(start, count); | ||
} | ||
|
||
return new R3.Factories.Range(start, count); | ||
public static Event<int, Unit> Range(int start, int count, CancellationToken cancellationToken) | ||
{ | ||
long max = ((long)start) + count - 1; | ||
if (count < 0 || max > int.MaxValue) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
|
||
public static Event<int, Unit> Range(int start, int count, CancellationToken cancellationToken) | ||
if (count == 0) | ||
{ | ||
long max = ((long)start) + count - 1; | ||
if (count < 0 || max > int.MaxValue) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
|
||
if (count == 0) | ||
{ | ||
return Empty<int>(); | ||
} | ||
|
||
return new R3.Factories.RangeC(start, count, cancellationToken); | ||
return Empty<int>(); | ||
} | ||
|
||
return new RangeC(start, count, cancellationToken); | ||
} | ||
} | ||
|
||
namespace R3.Factories | ||
internal sealed class Range(int start, int count) : Event<int, Unit> | ||
{ | ||
internal sealed class Range(int start, int count) : Event<int, Unit> | ||
protected override IDisposable SubscribeCore(Subscriber<int, Unit> subscriber) | ||
{ | ||
protected override IDisposable SubscribeCore(Subscriber<int, Unit> subscriber) | ||
for (int i = 0; i < count; i++) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
{ | ||
subscriber.OnNext(start + i); | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
subscriber.OnNext(start + i); | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
} | ||
} | ||
|
||
internal sealed class RangeC(int start, int count, CancellationToken cancellationToken) : Event<int, Unit> | ||
internal sealed class RangeC(int start, int count, CancellationToken cancellationToken) : Event<int, Unit> | ||
{ | ||
protected override IDisposable SubscribeCore(Subscriber<int, Unit> subscriber) | ||
{ | ||
protected override IDisposable SubscribeCore(Subscriber<int, Unit> subscriber) | ||
for (int i = 0; i < count; i++) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
return Disposable.Empty; | ||
} | ||
subscriber.OnNext(start + i); | ||
return Disposable.Empty; | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
subscriber.OnNext(start + i); | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,67 @@ | ||
namespace R3 | ||
namespace R3; | ||
|
||
public static partial class Event | ||
{ | ||
public static partial class Event | ||
// no scheduler(TimeProvider) overload | ||
// no infinitely overload | ||
|
||
public static Event<TMessage, Unit> Repeat<TMessage>(TMessage value, int count) | ||
{ | ||
// no scheduler(TimeProvider) overload | ||
// no infinitely overload | ||
if (count < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
|
||
public static Event<TMessage, Unit> Repeat<TMessage>(TMessage value, int count) | ||
if (count == 0) | ||
{ | ||
if (count < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
return Empty<TMessage>(); | ||
} | ||
|
||
if (count == 0) | ||
{ | ||
return Empty<TMessage>(); | ||
} | ||
return new Repeat<TMessage>(value, count); | ||
} | ||
|
||
return new Repeat<TMessage>(value, count); | ||
public static Event<TMessage, Unit> Repeat<TMessage>(TMessage value, int count, CancellationToken cancellationToken) | ||
{ | ||
if (count < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
|
||
public static Event<TMessage, Unit> Repeat<TMessage>(TMessage value, int count, CancellationToken cancellationToken) | ||
if (count == 0) | ||
{ | ||
if (count < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(count)); | ||
} | ||
|
||
if (count == 0) | ||
{ | ||
return Empty<TMessage>(); | ||
} | ||
|
||
return new RepeatC<TMessage>(value, count, cancellationToken); | ||
return Empty<TMessage>(); | ||
} | ||
|
||
return new RepeatC<TMessage>(value, count, cancellationToken); | ||
} | ||
} | ||
|
||
namespace R3.Factories | ||
internal sealed class Repeat<TMessage>(TMessage value, int count) : Event<TMessage, Unit> | ||
{ | ||
internal sealed class Repeat<TMessage>(TMessage value, int count) : Event<TMessage, Unit> | ||
protected override IDisposable SubscribeCore(Subscriber<TMessage, Unit> subscriber) | ||
{ | ||
protected override IDisposable SubscribeCore(Subscriber<TMessage, Unit> subscriber) | ||
for (int i = 0; i < count; i++) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
{ | ||
subscriber.OnNext(value); | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
subscriber.OnNext(value); | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
} | ||
} | ||
|
||
internal sealed class RepeatC<TMessage>(TMessage value, int count, CancellationToken cancellationToken) : Event<TMessage, Unit> | ||
internal sealed class RepeatC<TMessage>(TMessage value, int count, CancellationToken cancellationToken) : Event<TMessage, Unit> | ||
{ | ||
protected override IDisposable SubscribeCore(Subscriber<TMessage, Unit> subscriber) | ||
{ | ||
protected override IDisposable SubscribeCore(Subscriber<TMessage, Unit> subscriber) | ||
for (int i = 0; i < count; i++) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
return Disposable.Empty; | ||
} | ||
subscriber.OnNext(value); | ||
return Disposable.Empty; | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
subscriber.OnNext(value); | ||
} | ||
subscriber.OnCompleted(default); | ||
return Disposable.Empty; | ||
} | ||
} |
Oops, something went wrong.