環境:C# .Net Unity2021
1.同一個LCObject對同一個ObjectID做Save,是否平行處裡?
例如
[LCEngineFunction("Test1")]
public static async Task Test1EndPoint(
[LCEngineFunctionParam("objectID")] string objectID,
[LCEngineFunctionParam("times")] int times)
{
try
{
var tID = Thread.CurrentThread.ManagedThreadId;
Console.WriteLine($"Test1EndPoint tID={tID}");
var query = new LCQuery<LCObject>("Data");
var lcObj = await query.Get(objectID);
var tasks = new List<Task>();
for (int i = 0; i < times; i++)
{
lcObj["num"] = i;
tasks.Add(lcObj.Save());
}
await Task.WhenAll(tasks);
lcObj = await query.Get(objectID);
int num = (int)lcObj["num"]; // ??
Console.WriteLine($"Test1EndPoint num={num}");
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
2.多個LCObject對同一個ObjectID做Save,是否平行處裡?
例如
[LCEngineFunction("Test2")]
public static async Task Test2EndPoint(
[LCEngineFunctionParam("objectID")] string objectID,
[LCEngineFunctionParam("times")] int times)
{
try
{
var tID = Thread.CurrentThread.ManagedThreadId;
Console.WriteLine($"Test2EndPoint tID={tID}");
var query = new LCQuery<LCObject>("Data");
var lcObj = await query.Get(objectID); // obj 1
var lcObj2 = await query.Get(objectID); // obj 2
var tasks = new List<Task>();
for (int i = 0; i < times; i++)
{
lcObj["num"] = i;
tasks.Add(lcObj.Save());
}
for (int i = times; i < times * 2; i++)
{
lcObj2["num"] = i;
tasks.Add(lcObj2.Save());
}
await Task.WhenAll(tasks);
lcObj = await query.Get(objectID);
int num = (int)lcObj["num"]; // ??
Console.WriteLine($"Test2EndPoint num={num}");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
3.同一個LCUser在同一個Server Instance的同一個EndPoint是否會平行執行?
例如client端
var tasks = new List<Task>();
for(int i = 0;i< clientTimes;i++)
{
var task = LCCloud.RPC("Test1", new Dictionary<string, object>()
{
{ "objectID", objectID },
{ "times", serverTimes },
});
tasks.Add(task);
}
await Task.WhenAll(tasks);
4.同一個LCUser在同一個Server Instance上,不同EndPoint是否會平行執行?
例如client同時呼叫多次RPC Test1和Test2
5.同一個LCUser在Client同時呼叫多次同一個RPC,這些請求是否會交給同一個Server Instance處裡?
6.同一個LCUser在Client同時呼叫多次不同的RPC,這些請求是否會交給同一個Server Instance處裡?