Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ReLogic.Content.AssetRepository Class Reference

Async loading has been fully integrated into AssetRepository Assets which are asynchronously loaded will: More...

Classes

struct  ContinuationScheduler
 

Public Member Functions

IAsset[] GetLoadedAssets ()
 
 AssetRepository (AssetReaderCollection readers, IEnumerable< IContentSource > sources=null)
 
virtual void SetSources (IEnumerable< IContentSource > sources, AssetRequestMode mode=AssetRequestMode.ImmediateLoad)
 
virtual Asset< T > Request< T > (string assetName, AssetRequestMode mode=AssetRequestMode.AsyncLoad)
 
void TransferAllAssets ()
 
void TransferCompletedAssets ()
 
Asset< T > CreateUntracked< T > (Stream stream, string name, AssetRequestMode mode=AssetRequestMode.ImmediateLoad)
 
void Dispose ()
 

Static Public Member Functions

static void SetMainThread ()
 
static void ThrowIfNotMainThread ()
 

Protected Member Functions

IContentSource FindSourceForAsset (string assetName)
 
virtual void Dispose (bool disposing)
 

Protected Attributes

readonly Dictionary< string, IAsset_assets = new Dictionary<string, IAsset>()
 
readonly AssetReaderCollection _readers
 

Package Functions

Asset< T > Request< T > (string assetName)
 

Package Attributes

readonly ConcurrentQueue< Action > _assetTransferQueue = new ConcurrentQueue<Action>()
 

Properties

static bool IsMainThread [get]
 
IContentSource[] _sources [get, private set]
 
bool IsDisposed [get]
 
int PendingAssets [get]
 
int TotalAssets [get, private set]
 
int LoadedAssets [get, private set]
 
bool IsAsyncLoadingEnabled [get]
 
FailedToLoadAssetCustomAction AssetLoadFailHandler [get, set]
 

Private Member Functions

void Invoke (Action action)
 
void ReloadAssetsIfSourceChanged (AssetRequestMode mode)
 
void LoadAsset< T > (Asset< T > asset, AssetRequestMode mode)
 
async Task LoadAssetWithPotentialAsync< T > (Asset< T > asset, AssetRequestMode mode)
 
void SafelyWaitForLoad< T > (Asset< T > asset, Task loadTask, bool tracked)
 
async Task LoadUntracked< T > (Stream stream, IAssetReader reader, Asset< T > asset, AssetRequestMode mode)
 
void ForceReloadAsset (IAsset asset, AssetRequestMode mode)
 
void EnsureReloadActionExistsForType< T > ()
 
void ForceReloadAsset< T > (IAsset asset, AssetRequestMode mode)
 
void ThrowIfDisposed ()
 

Private Attributes

readonly Dictionary< Type, Action< IAsset, AssetRequestMode > > _typeSpecificReloadActions = new Dictionary<Type, Action<IAsset, AssetRequestMode>>()
 
readonly object _requestLock = new object()
 
bool _isDisposed
 
int _Remaining
 

Static Private Attributes

static Thread _mainThread
 

Detailed Description

Async loading has been fully integrated into AssetRepository Assets which are asynchronously loaded will:

  • be deserialized on the thread pool
  • return to the main thread if the asset can only be created there (for assets requiring GraphicsDevice)
  • become loaded at a defined time:
    • at the end of a frame or
    • when content sources are changing or
    • when requested by ImmediateLoad on the main thread

Assets which require main thread creation, but are requested via ImmediateLoad on a worker thread will:

  • be deserialized immediately on the worker thread
  • transition to asynchronous loading for creation

Definition at line 28 of file AssetRepository.cs.


The documentation for this class was generated from the following file: