Skip to content

Commit 68f2e83

Browse files
author
Oren (electricessence)
committed
Updated to 2.7.0
1 parent 3de40be commit 68f2e83

File tree

5 files changed

+82
-65
lines changed

5 files changed

+82
-65
lines changed

source/Open.Collections.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Part of the "Open" set of libraries.</Description>
1515
<PackageProjectUrl>https://github.com/electricessence/Open.Collections/</PackageProjectUrl>
1616
<RepositoryUrl>https://github.com/electricessence/Open.Collections/</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
18-
<Version>2.6.2</Version>
19-
<AssemblyVersion>2.6.2.0</AssemblyVersion>
20-
<FileVersion>2.6.2.0</FileVersion>
18+
<Version>2.7.0</Version>
19+
<AssemblyVersion>2.7.0.0</AssemblyVersion>
20+
<FileVersion>2.7.0.0</FileVersion>
2121
<PackageReleaseNotes></PackageReleaseNotes>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2323
</PropertyGroup>

source/Synchronized/LockSynchronizedList.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,9 @@
33

44
namespace Open.Collections.Synchronized
55
{
6-
public sealed class LockSynchronizedList<T> : LockSynchronizedCollectionWrapper<T, List<T>>, IList<T>
6+
public sealed class LockSynchronizedList<T> : LockSynchronizedListWrapper<T>
77
{
8-
98
public LockSynchronizedList() : base(new List<T>()) { }
109
public LockSynchronizedList(IEnumerable<T> collection) : base(new List<T>(collection)) { }
11-
12-
// This is a simplified version.
13-
// It could be possible to allow indexed values to change independently of one another.
14-
// If that fine grained of read-write control is necessary, then use the ThreadSafety utility and extensions.
15-
16-
/// <inheritdoc />
17-
public T this[int index]
18-
{
19-
// ReSharper disable once InconsistentlySynchronizedField
20-
get => InternalSource[index];
21-
// ReSharper disable once InconsistentlySynchronizedField
22-
set => InternalSource[index] = value;
23-
}
24-
25-
/// <inheritdoc />
26-
public int IndexOf(T item)
27-
{
28-
lock (Sync) return InternalSource.IndexOf(item);
29-
}
30-
31-
/// <inheritdoc />
32-
public void Insert(int index, T item)
33-
{
34-
lock (Sync) InternalSource.Insert(index, item);
35-
}
36-
37-
/// <inheritdoc />
38-
public void RemoveAt(int index)
39-
{
40-
lock (Sync) InternalSource.RemoveAt(index);
41-
}
42-
4310
}
4411
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Collections.Generic;
2+
3+
namespace Open.Collections.Synchronized
4+
{
5+
public class LockSynchronizedListWrapper<T> : LockSynchronizedCollectionWrapper<T, IList<T>>, IList<T>
6+
{
7+
8+
public LockSynchronizedListWrapper(IList<T> list) : base(list) { }
9+
10+
// This is a simplified version.
11+
// It could be possible to allow indexed values to change independently of one another.
12+
// If that fine grained of read-write control is necessary, then use the ThreadSafety utility and extensions.
13+
14+
/// <inheritdoc />
15+
public T this[int index]
16+
{
17+
// ReSharper disable once InconsistentlySynchronizedField
18+
get => InternalSource[index];
19+
// ReSharper disable once InconsistentlySynchronizedField
20+
set => InternalSource[index] = value;
21+
}
22+
23+
/// <inheritdoc />
24+
public int IndexOf(T item)
25+
{
26+
lock (Sync) return InternalSource.IndexOf(item);
27+
}
28+
29+
/// <inheritdoc />
30+
public void Insert(int index, T item)
31+
{
32+
lock (Sync) InternalSource.Insert(index, item);
33+
}
34+
35+
/// <inheritdoc />
36+
public void RemoveAt(int index)
37+
{
38+
lock (Sync) InternalSource.RemoveAt(index);
39+
}
40+
41+
}
42+
}
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
1-
using Open.Threading;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32

43
namespace Open.Collections.Synchronized
54
{
6-
public sealed class ReadWriteSynchronizedList<T> : ReadWriteSynchronizedCollectionWrapper<T, List<T>>, IList<T>
5+
public sealed class ReadWriteSynchronizedList<T> : ReadWriteSynchronizedListWrapper<T>
76
{
8-
97
public ReadWriteSynchronizedList() : base(new List<T>()) { }
108
public ReadWriteSynchronizedList(IEnumerable<T> collection) : base(new List<T>(collection)) { }
11-
12-
// This is a simplified version.
13-
// It could be possible to allow indexed values to change independently of one another.
14-
// If that fine grained of read-write control is necessary, then use the ThreadSafety utility and extensions.
15-
16-
/// <inheritdoc />
17-
public T this[int index]
18-
{
19-
get => InternalSource[index];
20-
set => InternalSource[index] = value;
21-
}
22-
23-
/// <inheritdoc />
24-
public int IndexOf(T item)
25-
=> Sync.ReadValue(() => InternalSource.IndexOf(item));
26-
27-
/// <inheritdoc />
28-
public void Insert(int index, T item)
29-
=> Sync.Write(() => InternalSource.Insert(index, item));
30-
31-
/// <inheritdoc />
32-
public void RemoveAt(int index)
33-
=> Sync.Write(() => InternalSource.RemoveAt(index));
34-
359
}
3610
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Open.Threading;
2+
using System.Collections.Generic;
3+
4+
namespace Open.Collections.Synchronized
5+
{
6+
public class ReadWriteSynchronizedListWrapper<T> : ReadWriteSynchronizedCollectionWrapper<T, IList<T>>, IList<T>
7+
{
8+
public ReadWriteSynchronizedListWrapper(IList<T> list) : base(list) { }
9+
10+
// This is a simplified version.
11+
// It could be possible to allow indexed values to change independently of one another.
12+
// If that fine grained of read-write control is necessary, then use the ThreadSafety utility and extensions.
13+
14+
/// <inheritdoc />
15+
public T this[int index]
16+
{
17+
get => InternalSource[index];
18+
set => InternalSource[index] = value;
19+
}
20+
21+
/// <inheritdoc />
22+
public int IndexOf(T item)
23+
=> Sync.ReadValue(() => InternalSource.IndexOf(item));
24+
25+
/// <inheritdoc />
26+
public void Insert(int index, T item)
27+
=> Sync.Write(() => InternalSource.Insert(index, item));
28+
29+
/// <inheritdoc />
30+
public void RemoveAt(int index)
31+
=> Sync.Write(() => InternalSource.RemoveAt(index));
32+
33+
}
34+
}

0 commit comments

Comments
 (0)