Class DataLayer
Base class for all data layers. Data Layer is a container for data that can be read and written to. Data Layer allows for parallel reading and writing of data. It tracks dependencies for reading and writing jobs.
If you want to read data immediately, call DataLayer.OpenToRead() before reading. If you want to write data immediately, call DataLayer.OpenToWrite() before writing. If you want to schedule a job that reads data, call DataLayer.PrepareToRead() before scheduling the job (returns a JobHandle to use as dependency in your job) If you want to schedule a job that writes data, call DataLayer.PrepareToWrite() before scheduling the job (returns a JobHandle to use as dependency in your job)
Inheritance
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class DataLayer : IDisposable, ICommitChanges
Fields
_isDirty
Declaration
protected bool _isDirty
Field Value
| Type | Description |
|---|---|
| bool |
_readJobsDependency
Declaration
protected JobHandle _readJobsDependency
Field Value
| Type | Description |
|---|---|
| JobHandle |
_version
Declaration
protected long _version
Field Value
| Type | Description |
|---|---|
| long |
_writeJobsDependency
Declaration
protected JobHandle _writeJobsDependency
Field Value
| Type | Description |
|---|---|
| JobHandle |
Properties
CombinedDependency
Returns a combined (Read+Write) dependency
Declaration
public JobHandle CombinedDependency { get; }
Property Value
| Type | Description |
|---|---|
| JobHandle |
IsDirty
True if the layer has been modified since the last time the flag was removed. To set a flag call SetDirty(isDirty) of the layer.
Declaration
public bool IsDirty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsDisposableItems
If true, means when layer is resized or disposed, all items that are removed will be disposed (see nested classes description for details as the process may be different from layer to layer)
Declaration
public abstract bool IsDisposableItems { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Length
Returns the number of items in the layer.
Declaration
public abstract int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
ReadDependency
Returns a dependency that must be completed before reading from the layer (Read dependency)
Declaration
public JobHandle ReadDependency { get; }
Property Value
| Type | Description |
|---|---|
| JobHandle |
Version
Every time the layer is set isDirty, the version is incremented. This allows to track changes in the layer and to invalidate caches that depend on the layer. If you see that the version is the same as your cached version, you can skip the update.
Declaration
public long Version { get; }
Property Value
| Type | Description |
|---|---|
| long |
WriteDependency
Returns a dependency that must be completed before writing to the layer (Write dependency)
Declaration
public JobHandle WriteDependency { get; }
Property Value
| Type | Description |
|---|---|
| JobHandle |
Methods
AddReadDependency(JobHandle)
Adds a read dependency to the layer. If you schedule a job that reads from the layer, call this method with JobHandle of your job as a parameter.
Declaration
public virtual JobHandle AddReadDependency(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | Read data JobHandle to be added to the ReadDependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
AddWriteDependency(JobHandle)
Adds a write dependency to the layer. If you schedule a job that writes to the layer, call this method with JobHandle of your job as a parameter.
Declaration
public virtual JobHandle AddWriteDependency(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | Write data JobHandle to be added to the WriteDependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
CommitChanges()
Sets the isDirty flag to true and increments the version. Call this function after you have modified the layer and want to mark the layer isDirty.
Declaration
public virtual void CommitChanges()
CompleteAllJobs()
Completes all reading and writing jobs.
Declaration
public virtual void CompleteAllJobs()
CompleteReadJobs()
Completes all reading jobs.
Declaration
public virtual void CompleteReadJobs()
CompleteWriteJobs()
Completes all writing jobs.
Declaration
public virtual void CompleteWriteJobs()
Dispose()
Completes all jobs and disposes the layer. If IsDisposableItems is true, all items in the layer will be disposed.
Declaration
public virtual void Dispose()
DisposeAllItems()
Disposes all items in the layer. Called on Dispose() if IsDisposableItems is true.
Declaration
public abstract void DisposeAllItems()
OpenToRead()
Completes all writing jobs. Call this method if you want to read from the layer immediately.
Declaration
public virtual void OpenToRead()
OpenToWrite()
Completes all reading and writing jobs. Call this method if you want to write to the layer immediately.
Declaration
public virtual void OpenToWrite()
PrepareToRead()
Returns a dependency that must be completed before reading from the layer (Write dependency)
Declaration
public virtual JobHandle PrepareToRead()
Returns
| Type | Description |
|---|---|
| JobHandle |
PrepareToWrite()
Returns a dependency that must be completed before writing to the layer (Read and Write dependencies combined)
Declaration
public virtual JobHandle PrepareToWrite()
Returns
| Type | Description |
|---|---|
| JobHandle |
SetDirty(bool)
Sets the isDirty flag. If isDirty is true, the version is incremented.
Declaration
public virtual void SetDirty(bool isDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isDirty | value to set a dirty flag to |
SetReadDependency(JobHandle)
Ovewrites a read dependency with a provided one.
Declaration
public virtual void SetReadDependency(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | JobHandle to ovewrite the ReadDependency with |
SetWriteDependency(JobHandle)
Overwrites a write dependency with a provided one.
Declaration
public virtual void SetWriteDependency(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | JobHandle to overwrite the WriteDependency with |