-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from nayato/cancel-schedule
Adds IEventExecutor.Schedule, proper cancellation of scheduled tasks
- Loading branch information
Showing
23 changed files
with
601 additions
and
157 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
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
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
24 changes: 24 additions & 0 deletions
24
src/DotNetty.Common/Concurrency/ActionScheduledAsyncTask.cs
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace DotNetty.Common.Concurrency | ||
{ | ||
using System; | ||
using System.Threading; | ||
|
||
sealed class ActionScheduledAsyncTask : ScheduledAsyncTask | ||
{ | ||
readonly Action action; | ||
|
||
public ActionScheduledAsyncTask(AbstractScheduledEventExecutor executor, Action action, PreciseTimeSpan deadline, CancellationToken cancellationToken) | ||
: base(executor, deadline, new TaskCompletionSource(), cancellationToken) | ||
{ | ||
this.action = action; | ||
} | ||
|
||
protected override void Execute() | ||
{ | ||
this.action(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace DotNetty.Common.Concurrency | ||
{ | ||
using System; | ||
|
||
sealed class ActionScheduledTask : ScheduledTask | ||
{ | ||
readonly Action action; | ||
|
||
public ActionScheduledTask(AbstractScheduledEventExecutor executor, Action action, PreciseTimeSpan deadline) | ||
: base(executor, deadline, new TaskCompletionSource()) | ||
{ | ||
this.action = action; | ||
} | ||
|
||
protected override void Execute() | ||
{ | ||
this.action(); | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace DotNetty.Common.Concurrency | ||
{ | ||
using System; | ||
|
||
public interface IScheduledRunnable : IRunnable, IScheduledTask, IComparable<IScheduledRunnable> | ||
{ | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace DotNetty.Common.Concurrency | ||
{ | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
|
||
public interface IScheduledTask | ||
{ | ||
bool Cancel(); | ||
|
||
PreciseTimeSpan Deadline { get; } | ||
|
||
Task Completion { get; } | ||
|
||
TaskAwaiter GetAwaiter(); | ||
} | ||
} |
Oops, something went wrong.