Skip to content

Commit 02b8d89

Browse files
committed
RpcCallback も DispatchEvent で発生するのでロックは完全に不要
1 parent dd9d1ec commit 02b8d89

File tree

1 file changed

+5
-14
lines changed
  • SoraUnitySdkExamples/Assets/SoraUnitySdk

1 file changed

+5
-14
lines changed

SoraUnitySdkExamples/Assets/SoraUnitySdk/Sora.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,7 @@ public void Dispose()
582582
p = IntPtr.Zero;
583583
}
584584

585-
lock (rpcResponseJsonQueue)
586-
{
587-
rpcResponseJsonQueue.Clear();
588-
}
585+
rpcResponseJsonQueue.Clear();
589586
pendingRpcRequests.Clear();
590587

591588
foreach (var adapter in audioTrackSinks.Values)
@@ -1262,10 +1259,7 @@ public Action<string, byte[]>? OnMessage
12621259
static private void RpcCallback(string json, IntPtr userdata)
12631260
{
12641261
var sora = GCHandle.FromIntPtr(userdata).Target as Sora;
1265-
lock (sora!.rpcResponseJsonQueue)
1266-
{
1267-
sora.rpcResponseJsonQueue.Enqueue(json);
1268-
}
1262+
sora!.rpcResponseJsonQueue.Enqueue(json);
12691263
}
12701264

12711265
// RPC リクエストタイムアウト時間算出のための基準時間を生成
@@ -1286,14 +1280,11 @@ void HandleRpcInternal()
12861280
while (true)
12871281
{
12881282
string responseJson;
1289-
lock (rpcResponseJsonQueue)
1283+
if (rpcResponseJsonQueue.Count == 0)
12901284
{
1291-
if (rpcResponseJsonQueue.Count == 0)
1292-
{
1293-
break;
1294-
}
1295-
responseJson = rpcResponseJsonQueue.Dequeue();
1285+
break;
12961286
}
1287+
responseJson = rpcResponseJsonQueue.Dequeue();
12971288

12981289
// レスポンスデータの JSON 文字列をパースして、リクエスト ID のみを抜き出します。
12991290
// ID が取得できない場合や JSON 文字列が不正な場合はレスポンス待ちと紐付けできないため捨てます。

0 commit comments

Comments
 (0)