-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ton of work to cache arrays of data for recycling
- Loading branch information
Showing
38 changed files
with
294 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Basis Server/BasisNetworkCore/Serializable/LocalAvatarSyncMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27
Basis Server/BasisNetworkCore/Serializable/OwnershipTransferMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
using LiteNetLib.Utils; | ||
using static SerializableBasis; | ||
|
||
namespace DarkRift.Basis_Common.Serializable | ||
{ | ||
public struct OwnershipTransferMessage | ||
public static partial class SerializableBasis | ||
{ | ||
public PlayerIdMessage playerIdMessage; | ||
public string ownershipID; | ||
public void Deserialize(NetDataReader Writer) | ||
public struct OwnershipTransferMessage | ||
{ | ||
playerIdMessage.Deserialize(Writer); | ||
Writer.Get(out ownershipID); | ||
} | ||
public void Serialize(NetDataWriter Writer) | ||
{ | ||
playerIdMessage.Serialize(Writer); | ||
Writer.Put(ownershipID); | ||
public PlayerIdMessage playerIdMessage; | ||
public string ownershipID; | ||
public void Deserialize(NetDataReader Writer) | ||
{ | ||
playerIdMessage.Deserialize(Writer); | ||
Writer.Get(out ownershipID); | ||
} | ||
public void Serialize(NetDataWriter Writer) | ||
{ | ||
playerIdMessage.Serialize(Writer); | ||
Writer.Put(ownershipID); | ||
} | ||
} | ||
} | ||
|
||
} |
3 changes: 0 additions & 3 deletions
3
Basis Server/BasisNetworkCore/Serializable/PlayerMetaDataMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Concurrent; | ||
|
||
namespace BasisNetworkCore | ||
{ | ||
public static class ThreadSafeMessagePool<T> where T : new() | ||
{ | ||
private static readonly ConcurrentStack<T> pool = new ConcurrentStack<T>(); | ||
private static readonly int maxPoolSize = 500; // Maximum allowed size of the pool | ||
|
||
public static T Rent() | ||
{ | ||
if (pool.TryPop(out T obj)) | ||
{ | ||
return obj; | ||
} | ||
return new T(); | ||
} | ||
|
||
public static void Return(T obj) | ||
{ | ||
if (pool.Count < maxPoolSize) // Check if the pool size is within the limit | ||
{ | ||
pool.Push(obj); | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Basis Server/BasisNetworkServer/BasisNetworking/BasisNetworkOwnership.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.