Skip to content

Commit

Permalink
Rename iterators to parallel-enumerable, Refactored ReadMe
Browse files Browse the repository at this point in the history
  • Loading branch information
fembina committed May 22, 2024
1 parent 0aba44d commit ce317d7
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 43 deletions.
51 changes: 43 additions & 8 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,52 @@
# <img src="Icon64.png" width="24" hspace="5" /> Talkie

Talkie is a comprehensive framework designed to simplify the development of bots across multiple messengers platforms.
> Talkie is under active development. The underlying C# framework libraries is subject to change.
With its functional interfaces, developers can write code once and deploy it on various platforms
such as Telegram, Discord, and more.
Talkie is a versatile framework designed to streamline the development of bots across various messaging platforms.

The framework is designed with extensibility in mind,
allowing developers to easily add new features and functionalities as needed.
It leverages functional interfaces for messaging cross-platform compatibility,
enabling developers to write code once and deploy it on platforms like Telegram and Discord.

Whether you're building a simple chatbot or a complex bot, Talkie's lightweight design, native AOT support, and parallel processing capabilities ensure optimal performance.

## <img src="Icon64.png" width="18" hspace="5" /> Features

- **Unified API**: Write code once and deploy it on multiple platforms.
- **Fast and Lightweight**: Talkie is designed to be fast and lightweight, making it ideal for use in resource-constrained environments or high-traffic, large-scale bots.
- **Native-AOT Support (Latest .NET 8)**: Talkie provides native Ahead-of-Time (AOT) compilation support with the latest .NET 8 framework, enabling developers to compile bots to native code for enhanced performance and memory efficiency.
- **Parallel Processing**: Talkie is optimized to leverage multi-core processors, empowering developers to create bots capable of handling multiple messages concurrently.
- **OOP and Functional Programming**: Talkie offers flexibility by supporting both object-oriented and functional programming paradigms, allowing developers to choose the style that best aligns with their preferences and project requirements.
- **Self-Contained and Independent**: Talkie is self-contained and does not rely on external libraries. This eliminates compatibility concerns, reduces the overall footprint, and simplifies deployment.
- **Cross-Platform Compatibility**: Talkie is engineered for cross-platform compatibility, enabling developers to write code once and deploy it seamlessly across diverse bot platforms, including Telegram, Discord, and more.
- **Extensible Architecture**: Talkie is designed with extensibility in mind, making it easy for developers to add new features, functionalities, and expand platform support as needed.
- **Comprehensive Functionality**: Talkie offers a wide array of features, and managing complex branched code for different bot platforms, all while simplifying code that would be more cumbersome on other platforms.

## <img src="Icon64.png" width="18" hspace="5" /> Usage

### <img src="Icon64.png" width="12" hspace="5" /> Add the Falko Team NuGet Repository:

Open your terminal and execute the following command, replacing placeholders with your GitHub credentials:

```bash
dotnet nuget add source "https://nuget.pkg.github.com/falko-team/index.json" --name falko-team --store-password-in-clear-text --username $YOUR_GITHUB_USERNAME --password $YOUR_GITHUB_ACCESS_TOKEN
```

### <img src="Icon64.png" width="12" hspace="5" /> Install the Talkie Platforms Package:

If you're using Telegram, install the Talkie Telegram Platform package:

```bash
dotnet add package Falko.Talkie.Platforms.Telegram
```

### <img src="Icon64.png" width="12" hspace="5" /> Explore the Examples:

To get started quickly, check out the [Examples](Examples) folder in the Talkie repository
for illustrative code samples and usage demonstrations.

## <img src="Icon64.png" width="18" hspace="5" /> License

This project is licensed under the [BSD 2-Clause License](License.md).

- **Extensible**: Easily add new features and functionalities as needed.
Contributions are welcome!

- **Cross-platform**: Supports multiple messengers platforms such as Telegram, Discord, and more.
**© 2024, Falko Team**
1 change: 0 additions & 1 deletion Sources.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<PropertyGroup Label="Assembly">
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<OutputType>Library</OutputType>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Talkie.Collections;

public static class DisposableSequenceExtensions
public static class EnumerableDisposableExtensions
{
public static void Add(this IEnumerableDisposable enumerableDisposables, Action dispose)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Talkie.Collections;
public partial class FrozenSequence<T>
{
[method: MethodImpl(MethodImplOptions.AggressiveInlining)]
private sealed class Iterator(T[] items, int itemsCount) : IIterator<T>
private sealed class ParallelEnumerator(T[] items, int itemsCount) : IParallelEnumerator<T>
{
private int _lastItemIndex = -1;

Expand Down
2 changes: 1 addition & 1 deletion Sources/Falko.Talkie.Core/Collections/FrozenSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ public FrozenSequence(IEnumerable<T> values)

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

public IIterator<T> GetIterator() => new Iterator(_items, _itemsCount);
public IParallelEnumerator<T> GetParallelEnumerator() => new ParallelEnumerator(_items, _itemsCount);
}
2 changes: 1 addition & 1 deletion Sources/Falko.Talkie.Core/Collections/IReadOnlySequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace Talkie.Collections;

public interface IReadOnlySequence<T> : IReadOnlyCollection<T>, IIterable<T>;
public interface IReadOnlySequence<T> : IReadOnlyCollection<T>, IParallelEnumerable<T>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ namespace Talkie.Collections;
public partial class RemovableSequence<T>
{
[method: MethodImpl(MethodImplOptions.AggressiveInlining)]
private sealed class Iterator(Node? first) : IIterator<T>
private sealed class ParallelEnumerator(Node? first) : IParallelEnumerator<T>
{
// ReSharper disable once ReplaceWithPrimaryConstructorParameter
private Node? _current = first;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
2 changes: 1 addition & 1 deletion Sources/Falko.Talkie.Core/Collections/RemovableSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ public Remover Add(T value)

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

public IIterator<T> GetIterator() => new Iterator(_first);
public IParallelEnumerator<T> GetParallelEnumerator() => new ParallelEnumerator(_first);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ namespace Talkie.Collections;
public partial class Sequence<T>
{
[method: MethodImpl(MethodImplOptions.AggressiveInlining)]
private sealed class Iterator(Node? first) : IIterator<T>
private sealed class ParallelEnumerator(Node? first) : IParallelEnumerator<T>
{
// ReSharper disable once ReplaceWithPrimaryConstructorParameter
private Node? _current = first;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
2 changes: 1 addition & 1 deletion Sources/Falko.Talkie.Core/Collections/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public void Add(T value)

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

public IIterator<T> GetIterator() => new Iterator(_first);
public IParallelEnumerator<T> GetParallelEnumerator() => new ParallelEnumerator(_first);
}
6 changes: 0 additions & 6 deletions Sources/Falko.Talkie.Core/Concurrent/IIterable.cs

This file was deleted.

6 changes: 6 additions & 0 deletions Sources/Falko.Talkie.Core/Concurrent/IParallelEnumerable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Talkie.Concurrent;

public interface IParallelEnumerable<T>
{
IParallelEnumerator<T> GetParallelEnumerator();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Talkie.Concurrent;

public interface IIterator<T>
public interface IParallelEnumerator<T>
{
bool TryMoveNext([MaybeNullWhen(false)] out T item);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Talkie.Concurrent;

internal sealed partial class IterablePartitioner<T>
internal sealed partial class ParallelEnumerablePartitioner<T>
{
private sealed class Enumerable(IIterator<T> iterator) : IEnumerable<T>
private sealed class Enumerable(IParallelEnumerator<T> parallelEnumerator) : IEnumerable<T>
{
public IEnumerator<T> GetEnumerator() => iterator.ToEnumerable();
public IEnumerator<T> GetEnumerator() => parallelEnumerator.ToEnumerable();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
Expand Down
9 changes: 0 additions & 9 deletions Sources/Falko.Talkie.Core/Concurrent/IteratorExtensions.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

namespace Talkie.Concurrent;

public static class IterableExtensions
public static class ParallelEnumerableExtensions
{
public static Partitioner<T> ToPartitioner<T>(this IIterable<T> iterable)
public static Partitioner<T> ToPartitioner<T>(this IParallelEnumerable<T> parallelEnumerable)
{
return new IterablePartitioner<T>(iterable);
return new ParallelEnumerablePartitioner<T>(parallelEnumerable);
}

public static SequenceParallelismCoordinator<T>.Static Parallelize<T>(this IReadOnlySequence<T> sequence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Talkie.Concurrent;

internal sealed partial class IterablePartitioner<T>(IIterable<T> iterable) : Partitioner<T>
internal sealed partial class ParallelEnumerablePartitioner<T>(IParallelEnumerable<T> parallelEnumerable) : Partitioner<T>
{
public override bool SupportsDynamicPartitions => true;

public override IList<IEnumerator<T>> GetPartitions(int partitionCount) => throw new NotSupportedException();

public override IEnumerable<T> GetDynamicPartitions() => new Enumerable(iterable.GetIterator());
public override IEnumerable<T> GetDynamicPartitions() => new Enumerable(parallelEnumerable.GetParallelEnumerator());
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Talkie.Concurrent;

internal sealed class IteratorEnumerator<T>(IIterator<T> iterator) : IEnumerator<T>
internal sealed class ParallelEnumeratorAdapter<T>(IParallelEnumerator<T> parallelEnumerator) : IEnumerator<T>
{
private T? _current;

public T Current => _current!;

object IEnumerator.Current => _current!;

public bool MoveNext() => iterator.TryMoveNext(out _current);
public bool MoveNext() => parallelEnumerator.TryMoveNext(out _current);

public void Reset() => throw new NotSupportedException();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Talkie.Concurrent;

public static class ParallelEnumeratorExtensions
{
public static IEnumerator<T> ToEnumerable<T>(this IParallelEnumerator<T> parallelEnumerator)
{
return new ParallelEnumeratorAdapter<T>(parallelEnumerator);
}
}

0 comments on commit ce317d7

Please sign in to comment.