فهرست منبع

[csharp] Thread safety for acquiring next VertexAttachment ID. https://github.com/EsotericSoftware/spine-runtimes/commit/8a78eb4cf5c6ca47e86e3589f95134df3ce30a06

pharan 8 سال پیش
والد
کامیت
61a5058a5c
1فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 10 1
      spine-csharp/src/Attachments/VertexAttachment.cs

+ 10 - 1
spine-csharp/src/Attachments/VertexAttachment.cs

@@ -34,8 +34,17 @@ namespace Spine {
 	/// <summary>>An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.</summary> 
 	/// <summary>>An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.</summary> 
 	public class VertexAttachment : Attachment {
 	public class VertexAttachment : Attachment {
 		static int nextID = 0;
 		static int nextID = 0;
+		static Object nextIdLock = new Object();
+		static int GetNextID () {
+			int returnValue;
+			lock (nextIdLock) {
+				returnValue = nextID;
+				nextID++;
+			}
+			return returnValue;
+		}
 
 
-		internal readonly int id = (nextID++ & 65535) << 11;
+		internal readonly int id = (VertexAttachment.GetNextID() & 65535) << 11;
 		internal int[] bones;
 		internal int[] bones;
 		internal float[] vertices;
 		internal float[] vertices;
 		internal int worldVerticesLength;
 		internal int worldVerticesLength;