Skip to content

Commit c0ae7cc

Browse files
committed
Fix doc of #82
1 parent 5bb1c18 commit c0ae7cc

File tree

1 file changed

+55
-49
lines changed

1 file changed

+55
-49
lines changed

CodeJam.Main/Threading/AwaitableNonDisposable.cs

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,68 @@
88

99
namespace CodeJam.Threading
1010
{
11-
/// <summary>
12-
/// An awaitable wrapper around a task whose result is <see cref="IDisposable"/>.
11+
/// <summary>
12+
/// An awaitable wrapper around a task whose result is <see cref="IDisposable"/>.
1313
/// The wrapper itself is not <see cref="IDisposable"/>.!--
1414
/// This prevents usage errors like <code>using (lock.AcquireAsync())</code> when the appropriate usage should be <code>using (await lock.AcquireAsync())</code>.
15-
/// </summary>
16-
/// <typeparam name="T">The type of the result of the underlying task.</typeparam>
17-
public struct AwaitableNonDisposable<T> where T : IDisposable
18-
{
19-
/// <summary>
20-
/// The underlying task.
21-
/// </summary>
22-
[NotNull] private readonly Task<T> _task;
15+
/// </summary>
16+
/// <typeparam name="T">The type of the result of the underlying task.</typeparam>
17+
public struct AwaitableNonDisposable<T> where T : IDisposable
18+
{
19+
/// <summary>
20+
/// The underlying task.
21+
/// </summary>
22+
[NotNull] private readonly Task<T> _task;
2323

24-
/// <summary>
25-
/// Initializes a new awaitable wrapper around the specified task.
26-
/// </summary>
27-
/// <param name="task">The underlying task to wrap. This may not be <c>null</c>.</param>
28-
public AwaitableNonDisposable([NotNull] Task<T> task)
29-
{
24+
/// <summary>
25+
/// Initializes a new awaitable wrapper around the specified task.
26+
/// </summary>
27+
/// <param name="task">The underlying task to wrap. This may not be <c>null</c>.</param>
28+
public AwaitableNonDisposable([NotNull] Task<T> task)
29+
{
3030
Code.NotNull(task, nameof(task));
3131

32-
_task = task;
33-
}
32+
_task = task;
33+
}
3434

35-
/// <summary>
36-
/// Returns the underlying task.
37-
/// </summary>
38-
public Task<T> AsTask()
39-
{
40-
return _task;
41-
}
35+
/// <summary>
36+
/// Returns the underlying task.
37+
/// </summary>
38+
/// <returns>Underlying task.</returns>
39+
[NotNull]
40+
public Task<T> AsTask()
41+
{
42+
return _task;
43+
}
4244

43-
/// <summary>
44-
/// Implicit conversion to the underlying task.
45-
/// </summary>
46-
/// <param name="source">The awaitable wrapper.</param>
47-
public static implicit operator Task<T>([NotNull] AwaitableNonDisposable<T> source)
48-
{
49-
return source.AsTask();
50-
}
45+
/// <summary>
46+
/// Implicit conversion to the underlying task.
47+
/// </summary>
48+
/// <param name="source">The awaitable wrapper.</param>
49+
/// <returns>Underlying task</returns>
50+
[NotNull]
51+
public static implicit operator Task<T>([NotNull] AwaitableNonDisposable<T> source)
52+
{
53+
return source.AsTask();
54+
}
5155

52-
/// <summary>
53-
/// Infrastructure. Returns the task awaiter for the underlying task.
54-
/// </summary>
55-
public TaskAwaiter<T> GetAwaiter()
56-
{
57-
return _task.GetAwaiter();
58-
}
56+
/// <summary>
57+
/// Infrastructure. Returns the task awaiter for the underlying task.
58+
/// </summary>
59+
/// <returns>Task awaiter for the underlying task.</returns>
60+
public TaskAwaiter<T> GetAwaiter()
61+
{
62+
return _task.GetAwaiter();
63+
}
5964

60-
/// <summary>
61-
/// Infrastructure. Returns a configured task awaiter for the underlying task.
62-
/// </summary>
63-
/// <param name="continueOnCapturedContext">Whether to attempt to marshal the continuation back to the captured context.</param>
64-
public ConfiguredTaskAwaitable<T> ConfigureAwait(bool continueOnCapturedContext)
65-
{
66-
return _task.ConfigureAwait(continueOnCapturedContext);
67-
}
68-
}
65+
/// <summary>
66+
/// Infrastructure. Returns a configured task awaiter for the underlying task.
67+
/// </summary>
68+
/// <param name="continueOnCapturedContext">Whether to attempt to marshal the continuation back to the captured context.</param>
69+
/// <returns>A configured task awaiter for the underlying task.</returns>
70+
public ConfiguredTaskAwaitable<T> ConfigureAwait(bool continueOnCapturedContext)
71+
{
72+
return _task.ConfigureAwait(continueOnCapturedContext);
73+
}
74+
}
6975
}

0 commit comments

Comments
 (0)