Skip to content

Commit d00fce0

Browse files
authored
Removed ref return, it was closure capture that was issue before (#22)
1 parent d61a1c6 commit d00fce0

8 files changed

Lines changed: 145 additions & 208 deletions

File tree

src/EcsR3/Computeds/Components/ComputedComponentGroup.cs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ public class ComputedComponentGroup<T1> : ComputedFromEntityGroup<ReadOnlyMemory
1717

1818
public LookupGroup Group { get; }
1919
private ComponentBatch<T1>[] _internalCache = Array.Empty<ComponentBatch<T1>>();
20-
public ref ReadOnlyMemory<ComponentBatch<T1>> Batches
21-
{
22-
get
23-
{
24-
if (IsDirty) { ForceRefresh(); }
25-
return ref ComputedData;
26-
}
27-
}
28-
20+
2921
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase, IComputedEntityGroup computedEntityGroup) : base(computedEntityGroup)
3022
{
3123
AllocationDatabase = allocationDatabase;
@@ -63,14 +55,6 @@ public class ComputedComponentGroup<T1, T2> : ComputedFromEntityGroup<ReadOnlyMe
6355
private ComponentBatch<T1, T2>[] _internalCache = Array.Empty<ComponentBatch<T1, T2>>();
6456

6557
public LookupGroup Group { get; }
66-
public ref ReadOnlyMemory<ComponentBatch<T1, T2>> Batches
67-
{
68-
get
69-
{
70-
if (IsDirty) { ForceRefresh(); }
71-
return ref ComputedData;
72-
}
73-
}
7458

7559
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase,
7660
IComputedEntityGroup computedEntityGroup) : base(computedEntityGroup)
@@ -120,14 +104,6 @@ public class ComputedComponentGroup<T1, T2, T3> : ComputedFromEntityGroup<ReadOn
120104
private ComponentBatch<T1, T2, T3>[] _internalCache = Array.Empty<ComponentBatch<T1, T2, T3>>();
121105

122106
public LookupGroup Group { get; }
123-
public ref ReadOnlyMemory<ComponentBatch<T1, T2, T3>> Batches
124-
{
125-
get
126-
{
127-
if (IsDirty) { ForceRefresh(); }
128-
return ref ComputedData;
129-
}
130-
}
131107

132108
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase, IComputedEntityGroup computedEntityGroup) : base(
133109
computedEntityGroup)
@@ -180,14 +156,6 @@ public class ComputedComponentGroup<T1, T2, T3, T4> : ComputedFromEntityGroup<Re
180156
private ComponentBatch<T1, T2, T3, T4>[] _internalCache = Array.Empty<ComponentBatch<T1, T2, T3, T4>>();
181157

182158
public LookupGroup Group { get; }
183-
public ref ReadOnlyMemory<ComponentBatch<T1,T2,T3,T4>> Batches
184-
{
185-
get
186-
{
187-
if (IsDirty) { ForceRefresh(); }
188-
return ref ComputedData;
189-
}
190-
}
191159

192160
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase, IComputedEntityGroup computedEntityGroup) : base(
193161
computedEntityGroup)
@@ -244,14 +212,6 @@ public class ComputedComponentGroup<T1, T2, T3, T4, T5> : ComputedFromEntityGrou
244212
private ComponentBatch<T1, T2, T3, T4, T5>[] _internalCache = Array.Empty<ComponentBatch<T1, T2, T3, T4, T5>>();
245213

246214
public LookupGroup Group { get; }
247-
public ref ReadOnlyMemory<ComponentBatch<T1,T2,T3,T4,T5>> Batches
248-
{
249-
get
250-
{
251-
if (IsDirty) { ForceRefresh(); }
252-
return ref ComputedData;
253-
}
254-
}
255215

256216
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase, IComputedEntityGroup computedEntityGroup) : base(
257217
computedEntityGroup)
@@ -312,14 +272,6 @@ public class ComputedComponentGroup<T1, T2, T3, T4, T5, T6> : ComputedFromEntity
312272
private ComponentBatch<T1, T2, T3, T4,T5,T6>[] _internalCache = Array.Empty<ComponentBatch<T1, T2, T3,T4,T5,T6>>();
313273

314274
public LookupGroup Group { get; }
315-
public ref ReadOnlyMemory<ComponentBatch<T1,T2,T3,T4,T5,T6>> Batches
316-
{
317-
get
318-
{
319-
if (IsDirty) { ForceRefresh(); }
320-
return ref ComputedData;
321-
}
322-
}
323275

324276
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase, IComputedEntityGroup computedEntityGroup) : base(
325277
computedEntityGroup)
@@ -384,14 +336,6 @@ public class ComputedComponentGroup<T1, T2, T3, T4, T5, T6, T7> : ComputedFromEn
384336
private ComponentBatch<T1, T2, T3, T4,T5,T6,T7>[] _internalCache = Array.Empty<ComponentBatch<T1, T2, T3,T4,T5,T6,T7>>();
385337

386338
public LookupGroup Group { get; }
387-
public ref ReadOnlyMemory<ComponentBatch<T1,T2,T3,T4,T5,T6,T7>> Batches
388-
{
389-
get
390-
{
391-
if (IsDirty) { ForceRefresh(); }
392-
return ref ComputedData;
393-
}
394-
}
395339

396340
public ComputedComponentGroup(IComponentTypeLookup componentTypeLookup, IEntityAllocationDatabase allocationDatabase, IComputedEntityGroup computedEntityGroup) : base(
397341
computedEntityGroup)

src/EcsR3/Computeds/Components/IComputedComponentGroup.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,22 @@ public interface IComputedComponentGroup : IComputedGroup
1313
public interface IComputedComponentGroup<T1> : ILazyComputed<ReadOnlyMemory<ComponentBatch<T1>>>,
1414
IComputedComponentGroup where T1 : IComponent
1515
{
16-
ref ReadOnlyMemory<ComponentBatch<T1>> Batches { get; }
1716
}
1817

1918
public interface IComputedComponentGroup<T1, T2> : ILazyComputed<ReadOnlyMemory<ComponentBatch<T1, T2>>>,
2019
IComputedComponentGroup where T1 : IComponent where T2 : IComponent
2120
{
22-
ref ReadOnlyMemory<ComponentBatch<T1, T2>> Batches { get; }
2321
}
2422

2523
public interface IComputedComponentGroup<T1, T2, T3> : ILazyComputed<ReadOnlyMemory<ComponentBatch<T1, T2, T3>>>,
2624
IComputedComponentGroup where T1 : IComponent where T2 : IComponent where T3 : IComponent
2725
{
28-
ref ReadOnlyMemory<ComponentBatch<T1, T2, T3>> Batches { get; }
2926
}
3027

3128
public interface
3229
IComputedComponentGroup<T1, T2, T3, T4> : ILazyComputed<ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4>>>,
3330
IComputedComponentGroup where T1 : IComponent where T2 : IComponent where T3 : IComponent where T4 : IComponent
3431
{
35-
ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4>> Batches { get; }
3632
}
3733

3834
public interface
@@ -43,7 +39,6 @@ public interface
4339
where T4 : IComponent
4440
where T5 : IComponent
4541
{
46-
ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5>> Batches { get; }
4742
}
4843

4944
public interface
@@ -55,7 +50,6 @@ public interface
5550
where T5 : IComponent
5651
where T6 : IComponent
5752
{
58-
ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6>> Batches { get; }
5953
}
6054

6155
public interface
@@ -69,6 +63,5 @@ public interface
6963
where T6 : IComponent
7064
where T7 : IComponent
7165
{
72-
ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6, T7>> Batches { get; }
7366
}
7467
}

src/EcsR3/Systems/Batching/Convention/BatchedMixedSystem.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public abstract class BatchedMixedSystem<T1, T2> : RawBatchedSystem<T1, T2>
1818
protected BatchedMixedSystem(IComponentDatabase componentDatabase, IEntityComponentAccessor entityComponentAccessor, IComputedComponentGroupRegistry computedComponentGroupRegistry, IThreadHandler threadHandler) : base(componentDatabase, entityComponentAccessor, computedComponentGroupRegistry, threadHandler)
1919
{}
2020

21-
protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2>> componentBatches, (T1[], T2[]) componentPools)
21+
protected override void ProcessGroup(ReadOnlyMemory<ComponentBatch<T1, T2>> componentBatches, (T1[], T2[]) componentPools)
2222
{
2323
if (ShouldMultithread)
2424
{
25-
ProcessGroupWithMultithreading(ref componentBatches, componentPools);
25+
ProcessGroupWithMultithreading(componentBatches, componentPools);
2626
return;
2727
}
2828

@@ -35,7 +35,7 @@ protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2>>
3535
}
3636
}
3737

38-
protected void ProcessGroupWithMultithreading(ref ReadOnlyMemory<ComponentBatch<T1, T2>> componentBatches,
38+
protected void ProcessGroupWithMultithreading(ReadOnlyMemory<ComponentBatch<T1, T2>> componentBatches,
3939
(T1[], T2[]) componentPools)
4040
{
4141
var (components1, components2) = componentPools;
@@ -59,11 +59,11 @@ protected BatchedMixedSystem(IComponentDatabase componentDatabase, IEntityCompon
5959
{
6060
}
6161

62-
protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3>> componentBatches, (T1[], T2[], T3[]) componentPools)
62+
protected override void ProcessGroup(ReadOnlyMemory<ComponentBatch<T1, T2, T3>> componentBatches, (T1[], T2[], T3[]) componentPools)
6363
{
6464
if (ShouldMultithread)
6565
{
66-
ProcessGroupWithMultithreading(ref componentBatches, componentPools);
66+
ProcessGroupWithMultithreading(componentBatches, componentPools);
6767
return;
6868
}
6969

@@ -77,7 +77,7 @@ protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T
7777
}
7878
}
7979

80-
protected void ProcessGroupWithMultithreading(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3>> componentBatches, (T1[], T2[], T3[]) componentPools)
80+
protected void ProcessGroupWithMultithreading(ReadOnlyMemory<ComponentBatch<T1, T2, T3>> componentBatches, (T1[], T2[], T3[]) componentPools)
8181
{
8282
var (components1, components2, components3) = componentPools;
8383
var closureBatches = componentBatches;
@@ -102,12 +102,12 @@ protected BatchedMixedSystem(IComponentDatabase componentDatabase, IEntityCompon
102102
{
103103
}
104104

105-
protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3,T4>> componentBatches, (T1[], T2[], T3[], T4[]) componentPools)
105+
protected override void ProcessGroup(ReadOnlyMemory<ComponentBatch<T1, T2, T3,T4>> componentBatches, (T1[], T2[], T3[], T4[]) componentPools)
106106
{
107107

108108
if (ShouldMultithread)
109109
{
110-
ProcessGroupWithMultithreading(ref componentBatches, componentPools);
110+
ProcessGroupWithMultithreading(componentBatches, componentPools);
111111
return;
112112
}
113113

@@ -121,7 +121,7 @@ protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T
121121
};
122122
}
123123

124-
protected void ProcessGroupWithMultithreading(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3,T4>> componentBatches, (T1[], T2[], T3[], T4[]) componentPools)
124+
protected void ProcessGroupWithMultithreading(ReadOnlyMemory<ComponentBatch<T1, T2, T3,T4>> componentBatches, (T1[], T2[], T3[], T4[]) componentPools)
125125
{
126126
var (components1, components2, components3, components4) = componentPools;
127127
var closureBatches = componentBatches;
@@ -146,11 +146,11 @@ public abstract class BatchedMixedSystem<T1, T2, T3, T4, T5> : RawBatchedSystem<
146146
protected BatchedMixedSystem(IComponentDatabase componentDatabase, IEntityComponentAccessor entityComponentAccessor, IComputedComponentGroupRegistry computedComponentGroupRegistry, IThreadHandler threadHandler) : base(componentDatabase, entityComponentAccessor, computedComponentGroupRegistry, threadHandler)
147147
{}
148148

149-
protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5>> componentBatches, (T1[], T2[], T3[], T4[], T5[]) componentPools)
149+
protected override void ProcessGroup(ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5>> componentBatches, (T1[], T2[], T3[], T4[], T5[]) componentPools)
150150
{
151151
if (ShouldMultithread)
152152
{
153-
ProcessGroupWithMultithreading(ref componentBatches, componentPools);
153+
ProcessGroupWithMultithreading(componentBatches, componentPools);
154154
return;
155155
}
156156

@@ -165,7 +165,7 @@ protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T
165165
}
166166
}
167167

168-
protected void ProcessGroupWithMultithreading(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5>> componentBatches, (T1[], T2[], T3[], T4[], T5[]) componentPools)
168+
protected void ProcessGroupWithMultithreading(ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5>> componentBatches, (T1[], T2[], T3[], T4[], T5[]) componentPools)
169169
{
170170
var (components1, components2, components3, components4, components5) = componentPools;
171171
var closureBatches = componentBatches;
@@ -192,12 +192,12 @@ public abstract class BatchedMixedSystem<T1, T2, T3, T4, T5, T6> : RawBatchedSys
192192
protected BatchedMixedSystem(IComponentDatabase componentDatabase, IEntityComponentAccessor entityComponentAccessor, IComputedComponentGroupRegistry computedComponentGroupRegistry, IThreadHandler threadHandler) : base(componentDatabase, entityComponentAccessor, computedComponentGroupRegistry, threadHandler)
193193
{}
194194

195-
protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[]) componentPools)
195+
protected override void ProcessGroup(ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[]) componentPools)
196196
{
197197

198198
if (ShouldMultithread)
199199
{
200-
ProcessGroupWithMultithreading(ref componentBatches, componentPools);
200+
ProcessGroupWithMultithreading(componentBatches, componentPools);
201201
return;
202202
}
203203

@@ -212,7 +212,7 @@ protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T
212212
}
213213
}
214214

215-
protected void ProcessGroupWithMultithreading(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[]) componentPools)
215+
protected void ProcessGroupWithMultithreading(ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[]) componentPools)
216216
{
217217
var (components1, components2, components3, components4, components5, components6) = componentPools;
218218
var closureBatches = componentBatches;
@@ -241,11 +241,11 @@ protected BatchedMixedSystem(IComponentDatabase componentDatabase, IEntityCompon
241241
{
242242
}
243243

244-
protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6, T7>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) componentPools)
244+
protected override void ProcessGroup(ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6, T7>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) componentPools)
245245
{
246246
if (ShouldMultithread)
247247
{
248-
ProcessGroupWithMultithreading(ref componentBatches, componentPools);
248+
ProcessGroupWithMultithreading(componentBatches, componentPools);
249249
return;
250250
}
251251

@@ -261,7 +261,7 @@ protected override void ProcessGroup(ref ReadOnlyMemory<ComponentBatch<T1, T2, T
261261
}
262262
}
263263

264-
protected void ProcessGroupWithMultithreading(ref ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6, T7>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) componentPools)
264+
protected void ProcessGroupWithMultithreading(ReadOnlyMemory<ComponentBatch<T1, T2, T3, T4, T5, T6, T7>> componentBatches, (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) componentPools)
265265
{
266266
var (components1, components2, components3, components4, components5, components6, components7) = componentPools;
267267
var closureBatches = componentBatches;

0 commit comments

Comments
 (0)