Skip to content

Commit

Permalink
static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloszKrajewski committed Apr 2, 2022
1 parent 20c2ab1 commit 9781cb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.0.2 (2021/04/02)
## 0.0.3 (2021/04/02)
* ADDED: AliveKeeper
* ADDED: BatchBuilder
6 changes: 3 additions & 3 deletions Common.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<Version>0.0.2</Version>
<AssemblyVersion>0.0.2</AssemblyVersion>
<FileVersion>0.0.2</FileVersion>
<Version>0.0.3</Version>
<AssemblyVersion>0.0.3</AssemblyVersion>
<FileVersion>0.0.3</FileVersion>
</PropertyGroup>
<PropertyGroup>
<PackageId>$(AssemblyName)</PackageId>
Expand Down
24 changes: 20 additions & 4 deletions src/K4os.Async.Toys/Agent.static.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ public partial class Agent
/// <param name="action">Action to be executed (continuously) by agent.</param>
/// <param name="logger">Logger to be used (can be <c>null</c>)</param>
/// <returns>New agent.</returns>
public Agent Create(Func<IAgentContext, Task> action, ILogger? logger = null)
public static Agent Create(Func<IAgentContext, Task> action, ILogger? logger = null) =>
new(action, logger);

/// <summary>Creates and starts new agent with inbox queue.</summary>
/// <param name="action">Action to be executed (continuously) by agent.</param>
/// <param name="logger">Logger to be used (can be <c>null</c>)</param>
/// <returns>New agent.</returns>
public static Agent<T> Create<T>(
Func<IAgentContext<T>, Task> action, ILogger? logger = null) =>
new(action, logger);

/// <summary>Creates and starts new agent.</summary>
/// <param name="action">Action to be executed (continuously) by agent.</param>
/// <param name="logger">Logger to be used (can be <c>null</c>)</param>
/// <returns>New agent.</returns>
public static Agent Launch(Func<IAgentContext, Task> action, ILogger? logger = null)
{
var agent = new Agent(action, logger);
var agent = Create(action, logger);
agent.Start();
return agent;
}
Expand All @@ -21,9 +36,10 @@ public Agent Create(Func<IAgentContext, Task> action, ILogger? logger = null)
/// <param name="action">Action to be executed (continuously) by agent.</param>
/// <param name="logger">Logger to be used (can be <c>null</c>)</param>
/// <returns>New agent.</returns>
public Agent<T> Create<T>(Func<IAgentContext<T>, Task> action, ILogger? logger = null)
public static Agent<T> Launch<T>(
Func<IAgentContext<T>, Task> action, ILogger? logger = null)
{
var agent = new Agent<T>(action, logger);
var agent = Create(action, logger);
agent.Start();
return agent;
}
Expand Down

0 comments on commit 9781cb4

Please sign in to comment.