本文整理汇总了C#中Server.SaveMetrics类的典型用法代码示例。如果您正苦于以下问题:C# SaveMetrics类的具体用法?C# SaveMetrics怎么用?C# SaveMetrics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SaveMetrics类属于Server命名空间,在下文中一共展示了SaveMetrics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public override void Save( SaveMetrics metrics )
{
SaveMobiles( metrics );
SaveItems( metrics );
SaveGuilds( metrics );
SaveMaps( metrics );
}
示例2: Save
public override void Save(SaveMetrics metrics, bool permitBackgroundWrite)
{
_metrics = metrics;
OpenFiles();
var saveTasks = new Task[4];
saveTasks[0] = SaveItems();
saveTasks[1] = SaveMobiles();
saveTasks[2] = SaveGuilds();
saveTasks[3] = SaveData();
SaveTypeDatabases();
if (permitBackgroundWrite)
{
//This option makes it finish the writing to disk in the background, continuing even after Save() returns.
Task.Factory.ContinueWhenAll(
saveTasks,
_ =>
{
CloseFiles();
World.NotifyDiskWriteComplete();
});
}
else
{
Task.WaitAll(saveTasks); //Waits for the completion of all of the tasks(committing to disk)
CloseFiles();
}
}
示例3: SaveGuilds
protected void SaveGuilds( SaveMetrics metrics )
{
GenericWriter idx;
GenericWriter bin;
if ( World.SaveType == World.SaveOption.Normal ) {
idx = new BinaryFileWriter( World.GuildIndexPath, false );
bin = new BinaryFileWriter( World.GuildDataPath, true );
} else {
idx = new AsyncWriter( World.GuildIndexPath, false );
bin = new AsyncWriter( World.GuildDataPath, true );
}
idx.Write( ( int ) BaseGuild.List.Count );
foreach ( BaseGuild guild in BaseGuild.List.Values ) {
long start = bin.Position;
idx.Write( ( int ) 0 );//guilds have no typeid
idx.Write( ( int ) guild.Id );
idx.Write( ( long ) start );
guild.Serialize( bin );
if ( metrics != null ) {
metrics.OnGuildSaved( ( int ) ( bin.Position - start ) );
}
idx.Write( ( int ) ( bin.Position - start ) );
}
idx.Close();
bin.Close();
}
示例4: Save
public override void Save( SaveMetrics metrics, bool permitBackgroundWrite )
{
this.PermitBackgroundWrite = permitBackgroundWrite;
#if Framework_4_0
Task saveItemsTask = Task.Factory.StartNew(() => SaveItems(metrics));
#else
Thread saveThread = new Thread( delegate() {
SaveItems(metrics);
} );
saveThread.Name = "Item Save Subset";
saveThread.Start();
#endif
SaveMobiles( metrics );
SaveGuilds( metrics );
SaveMaps( metrics );
#if Framework_4_0
saveItemsTask.Wait();
#else
saveThread.Join();
#endif
if (permitBackgroundWrite && UseSequentialWriters) //If we're permitted to write in the background, but we don't anyways, then notify.
World.NotifyDiskWriteComplete();
}
示例5: Save
public override void Save(SaveMetrics metrics, bool permitBackgroundWrite)
{
_permitBackgroundWrite = permitBackgroundWrite;
SaveMobiles(metrics);
SaveItems(metrics);
SaveGuilds(metrics);
if (permitBackgroundWrite && UseSequentialWriters) //If we're permitted to write in the background, but we don't anyways, then notify.
World.NotifyDiskWriteComplete();
}
示例6: SaveMobiles
protected void SaveMobiles(SaveMetrics metrics)
{
Dictionary<Serial, Mobile> mobiles = World.Mobiles;
GenericWriter idx;
GenericWriter tdb;
GenericWriter bin;
if (UseSequentialWriters)
{
idx = new BinaryFileWriter(World.MobileIndexPath, false);
tdb = new BinaryFileWriter(World.MobileTypesPath, false);
bin = new BinaryFileWriter(World.MobileDataPath, true);
}
else
{
idx = new AsyncWriter(World.MobileIndexPath, false);
tdb = new AsyncWriter(World.MobileTypesPath, false);
bin = new AsyncWriter(World.MobileDataPath, true);
}
idx.Write(mobiles.Count);
foreach (Mobile m in mobiles.Values)
{
long start = bin.Position;
idx.Write(m._TypeRef);
idx.Write(m.Serial);
idx.Write(start);
m.Serialize(bin);
if (metrics != null)
{
metrics.OnMobileSaved((int)(bin.Position - start));
}
idx.Write((int)(bin.Position - start));
m.FreeCache();
}
tdb.Write(World.m_MobileTypes.Count);
foreach (Type t in World.m_MobileTypes)
{
tdb.Write(t.FullName);
}
idx.Close();
tdb.Close();
bin.Close();
}
示例7: SequentialFileWriter
public SequentialFileWriter(string path, SaveMetrics metrics)
{
if (path == null)
{
throw new ArgumentNullException("path");
}
this.metrics = metrics;
fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
fileQueue = new FileQueue(Math.Max(1, FileOperations.Concurrency), FileCallback);
}
示例8: Save
public override void Save( SaveMetrics metrics ) {
Thread saveThread = new Thread( delegate() {
SaveItems( metrics );
} );
saveThread.Name = "Item Save Subset";
saveThread.Start();
SaveMobiles( metrics );
SaveGuilds( metrics );
saveThread.Join();
}
示例9: SaveMobiles
protected void SaveMobiles( SaveMetrics metrics ) {
Dictionary<Serial, Mobile> mobiles = World.Mobiles;
GenericWriter idx;
GenericWriter tdb;
GenericWriter bin;
if ( World.SaveType == World.SaveOption.Normal ) {
idx = new BinaryFileWriter( World.MobileIndexPath, false );
tdb = new BinaryFileWriter( World.MobileTypesPath, false );
bin = new BinaryFileWriter( World.MobileDataPath, true );
} else {
idx = new AsyncWriter( World.MobileIndexPath, false );
tdb = new AsyncWriter( World.MobileTypesPath, false );
bin = new AsyncWriter( World.MobileDataPath, true );
}
idx.Write( ( int ) mobiles.Count );
foreach ( Mobile m in mobiles.Values ) {
long start = bin.Position;
idx.Write( ( int ) m.m_TypeRef );
idx.Write( ( int ) m.Serial );
idx.Write( ( long ) start );
m.Serialize( bin );
if ( metrics != null ) {
metrics.OnMobileSaved( ( int ) ( bin.Position - start ) );
}
idx.Write( ( int ) ( bin.Position - start ) );
m.FreeCache();
}
tdb.Write( ( int ) World.m_MobileTypes.Count );
for ( int i = 0; i < World.m_MobileTypes.Count; ++i )
tdb.Write( World.m_MobileTypes[i].FullName );
idx.Close();
tdb.Close();
bin.Close();
}
示例10: Save
public override void Save( SaveMetrics metrics, bool permitBackgroundWrite )
{
this.PermitBackgroundWrite = permitBackgroundWrite;
Thread saveThread = new Thread( delegate() {
SaveItems(metrics);
} );
saveThread.Name = "Item Save Subset";
saveThread.Start();
SaveMobiles(metrics);
SaveGuilds(metrics);
saveThread.Join();
if (permitBackgroundWrite && UseSequentialWriters) //If we're permitted to write in the background, but we don't anyways, then notify.
World.NotifyDiskWriteComplete();
}
示例11: SaveItems
protected void SaveItems(SaveMetrics metrics)
{
Dictionary<Serial, Item> items = World.Items;
GenericWriter idx;
GenericWriter tdb;
GenericWriter bin;
if (UseSequentialWriters)
{
idx = new BinaryFileWriter( World.ItemIndexPath, false );
tdb = new BinaryFileWriter( World.ItemTypesPath, false );
bin = new BinaryFileWriter( World.ItemDataPath, true );
} else {
idx = new AsyncWriter( World.ItemIndexPath, false );
tdb = new AsyncWriter( World.ItemTypesPath, false );
bin = new AsyncWriter( World.ItemDataPath, true );
}
idx.Write( ( int ) items.Count );
foreach ( Item item in items.Values ) {
if ( item.Decays && item.Parent == null && item.Map != Map.Internal && ( item.LastMoved + item.DecayTime ) <= DateTime.Now ) {
_decayQueue.Enqueue( item );
}
long start = bin.Position;
idx.Write( ( int ) item.m_TypeRef );
idx.Write( ( int ) item.Serial );
idx.Write( ( long ) start );
item.Serialize( bin );
if ( metrics != null ) {
metrics.OnItemSaved( ( int ) ( bin.Position - start ) );
}
idx.Write( ( int ) ( bin.Position - start ) );
item.FreeCache();
}
tdb.Write( ( int ) World.m_ItemTypes.Count );
for ( int i = 0; i < World.m_ItemTypes.Count; ++i )
tdb.Write( World.m_ItemTypes[i].FullName );
idx.Close();
tdb.Close();
bin.Close();
}
示例12: Save
public abstract void Save( SaveMetrics metrics );
示例13: Save
public abstract void Save(SaveMetrics metrics, bool permitBackgroundWrite);
示例14: SaveData
protected void SaveData(SaveMetrics metrics)
{
Dictionary<CustomSerial, SaveData> data = World.Data;
GenericWriter indexWriter;
GenericWriter typeWriter;
GenericWriter dataWriter;
if (this.UseSequentialWriters)
{
indexWriter = new BinaryFileWriter(World.DataIndexPath, false);
typeWriter = new BinaryFileWriter(World.DataTypesPath, false);
dataWriter = new BinaryFileWriter(World.DataBinaryPath, true);
}
else
{
indexWriter = new AsyncWriter(World.DataIndexPath, false);
typeWriter = new AsyncWriter(World.DataTypesPath, false);
dataWriter = new AsyncWriter(World.DataBinaryPath, true);
}
indexWriter.Write(data.Count);
foreach (SaveData saveData in data.Values)
{
long start = dataWriter.Position;
indexWriter.Write(saveData._TypeID);
indexWriter.Write((int)saveData.Serial);
indexWriter.Write(start);
saveData.Serialize(dataWriter);
if (metrics != null)
metrics.OnDataSaved((int)(dataWriter.Position - start));
indexWriter.Write((int)(dataWriter.Position - start));
}
typeWriter.Write(World._DataTypes.Count);
for (int i = 0; i < World._DataTypes.Count; ++i)
typeWriter.Write(World._DataTypes[i].FullName);
indexWriter.Close();
typeWriter.Close();
dataWriter.Close();
}
示例15: SaveMaps
protected void SaveMaps( SaveMetrics metrics )
{
Dictionary<Serial, BaseInstanceMap> maps = World.Maps;
GenericWriter idx;
GenericWriter tdb;
GenericWriter bin;
if (UseSequentialWriters)
{
idx = new BinaryFileWriter( World.MapIndexPath, false );
tdb = new BinaryFileWriter( World.MapTypesPath, false );
bin = new BinaryFileWriter( World.MapDataPath, true );
}
else
{
idx = new AsyncWriter( World.MapIndexPath, false );
tdb = new AsyncWriter( World.MapTypesPath, false );
bin = new AsyncWriter( World.MapDataPath, true );
}
idx.Write( ( int ) maps.Count );
foreach ( BaseInstanceMap map in maps.Values )
{
if ( map.Decays )
_decayMapQueue.Enqueue( map );
long start = bin.Position;
idx.Write( ( int ) map.TypeReference );
idx.Write( ( int ) map.Serial );
idx.Write( ( long ) start );
map.Serialize( bin );
if ( metrics != null )
metrics.OnMapSaved( ( int ) ( bin.Position - start ) );
idx.Write( ( int ) ( bin.Position - start ) );
}
tdb.Write( ( int ) World.m_InstanceMapTypes.Count );
for ( int i = 0; i < World.m_InstanceMapTypes.Count; ++i )
tdb.Write( World.m_InstanceMapTypes[i].FullName );
idx.Close();
tdb.Close();
bin.Close();
}