Skip to content

Commit 9dd4f4f

Browse files
Merge branch 'master' into feature/async-event
2 parents 75a425c + 01b1670 commit 9dd4f4f

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

HandyIpc/Core/AsyncPool.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ namespace HandyIpc.Core
55
{
66
public sealed class AsyncPool<TValue> : PoolBase<TValue> where TValue : IDisposable
77
{
8-
private readonly Func<Task<TValue>> _factory;
9-
private readonly Func<TValue, Task<bool>> _checkValue;
8+
private readonly Func<Task<T>> _factory;
9+
private readonly Func<T, Task<bool>> _checkValue;
1010

1111
public AsyncPool(Func<Task<TValue>> factory, Func<TValue, Task<bool>> checkValue)
1212
{
1313
_factory = factory;
1414
_checkValue = checkValue;
1515
}
1616

17-
public async Task<RentedValue<TValue>> RentAsync()
17+
public async Task<RentedValue<T>> RentAsync()
1818
{
19-
CheckDisposed("AsyncPool");
19+
CheckDisposed(nameof(AsyncPool<T>));
2020

21-
TValue value = await TakeOrCreateValue();
22-
return new RentedValue<TValue>(value, ReturnValue);
21+
T value = await TakeOrCreateValue();
22+
return new RentedValue<T>(value, ReturnValue);
2323

2424
// Local method
25-
void ReturnValue(TValue rentedValue) => Cache.Add(rentedValue);
25+
void ReturnValue(T rentedValue) => Cache.Add(rentedValue);
2626
}
2727

28-
private async Task<TValue> TakeOrCreateValue()
28+
private async Task<T> TakeOrCreateValue()
2929
{
30-
TValue result;
30+
T result;
3131
while (!Cache.TryTake(out result) || !await _checkValue(result))
3232
{
3333
Cache.Add(await _factory());

HandyIpc/Core/Pool.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ namespace HandyIpc.Core
44
{
55
public sealed class Pool<TValue> : PoolBase<TValue> where TValue : IDisposable
66
{
7-
private readonly Func<TValue> _factory;
8-
private readonly Func<TValue, bool> _checkValue;
7+
private readonly Func<T> _factory;
8+
private readonly Func<T, bool> _checkValue;
99

1010
public Pool(Func<TValue> factory, Func<TValue, bool> checkValue)
1111
{
1212
_factory = factory;
1313
_checkValue = checkValue;
1414
}
1515

16-
public RentedValue<TValue> Rent()
16+
public RentedValue<T> Rent()
1717
{
18-
CheckDisposed("Pool");
18+
CheckDisposed(nameof(Pool<T>));
1919

20-
TValue value = TakeOrCreateValue();
21-
return new RentedValue<TValue>(value, ReturnValue);
20+
T value = TakeOrCreateValue();
21+
return new RentedValue<T>(value, ReturnValue);
2222

2323
// Local method
24-
void ReturnValue(TValue rentedValue) => Cache.Add(rentedValue);
24+
void ReturnValue(T rentedValue) => Cache.Add(rentedValue);
2525
}
2626

27-
private TValue TakeOrCreateValue()
27+
private T TakeOrCreateValue()
2828
{
29-
TValue result;
29+
T result;
3030
while (!Cache.TryTake(out result) || !_checkValue(result))
3131
{
3232
Cache.Add(_factory());

HandyIpc/Core/RentedValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace HandyIpc.Core
88

99
public TValue Value { get; }
1010

11-
internal RentedValue(TValue value, Action<TValue> dispose)
11+
public RentedValue(TValue value, Action<TValue> dispose)
1212
{
1313
_dispose = dispose;
1414
Value = value;

0 commit comments

Comments
 (0)