public ETTask <IResponse> Call(IRequest request) { int rpcId = ++RpcId; var tcs = new ETTaskCompletionSource <IResponse>(); this.requestCallback[rpcId] = (response) => { if (response is ErrorResponse) { tcs.SetException(new Exception($"Rpc error: {MongoHelper.ToJson(response)}")); return; } if (ErrorCode.IsRpcNeedThrowException(response.Error)) { tcs.SetException(new Exception($"Rpc error: {MongoHelper.ToJson(response)}")); return; } tcs.SetResult(response); }; request.RpcId = rpcId; this.Send(request); return(tcs.Task); }
public void Run() { ETTaskCompletionSource tcs = this.Callback; this.GetParent <TimerComponent>().Remove(this.Id); tcs.SetResult(); }
public void Notify(CoroutineLockType coroutineLockType, long key) { CoroutineLockQueueType coroutineLockQueueType = this.list[(int)coroutineLockType]; if (!coroutineLockQueueType.TryGetValue(key, out CoroutineLockQueue queue)) { throw new Exception($"first work notify not find queue"); } if (queue.Count == 0) { coroutineLockQueueType.Remove(key); queue.Dispose(); return; } ETTaskCompletionSource <CoroutineLock> tcs = queue.Dequeue(); tcs.SetResult(EntityFactory.CreateWithParent <CoroutineLock, CoroutineLockType, long>(this, coroutineLockType, key)); }