Adding UnitTask support via USE_UNITASK compile define
Publish PHP Package / docker (push) Successful in 6s
Details
Publish PHP Package / docker (push) Successful in 6s
Details
This commit is contained in:
parent
1287703435
commit
5a1b01ea20
|
@ -4,6 +4,9 @@ using System.Threading.Tasks;
|
|||
using System.Collections.Generic;
|
||||
using metagen;
|
||||
using BitGames.Bits;
|
||||
#if USE_UNITASK
|
||||
using Cysharp.Threading.Tasks;
|
||||
#endif
|
||||
{%- for use in uses ~%}
|
||||
using {{use}};
|
||||
{%- endfor ~%}
|
||||
|
@ -16,7 +19,12 @@ namespace {{namespace}}
|
|||
|
||||
public interface IRpcCaller
|
||||
{
|
||||
Task CallRpc(metagen.IRpc rpc);
|
||||
#if USE_UNITASK
|
||||
UniTask
|
||||
#else
|
||||
Task
|
||||
#endif
|
||||
CallRpc(metagen.IRpc rpc);
|
||||
}
|
||||
|
||||
public interface IApiBase
|
||||
|
@ -26,7 +34,15 @@ public interface IApiBase
|
|||
|
||||
public interface IRpcCallBuilder<TRpc> where TRpc : metagen.IRpc
|
||||
{
|
||||
public Task<TRpc> Call();
|
||||
public
|
||||
|
||||
#if USE_UNITASK
|
||||
UniTask<TRpc>
|
||||
#else
|
||||
Task<TRpc>
|
||||
#endif
|
||||
|
||||
Call();
|
||||
}
|
||||
|
||||
public struct RpcCallBuilder<TRpc> : IRpcCallBuilder<TRpc> where TRpc : IRpc
|
||||
|
@ -40,7 +56,13 @@ public struct RpcCallBuilder<TRpc> : IRpcCallBuilder<TRpc> where TRpc : IRpc
|
|||
this.rpc = rpc;
|
||||
}
|
||||
|
||||
public async Task<TRpc> Call()
|
||||
public async
|
||||
#if USE_UNITASK
|
||||
UniTask<TRpc>
|
||||
#else
|
||||
Task<TRpc>
|
||||
#endif
|
||||
Call()
|
||||
{
|
||||
await clt.CallRpc(rpc);
|
||||
return rpc;
|
||||
|
@ -56,10 +78,17 @@ public struct MockRpcCallBuilder<TRpc> : IRpcCallBuilder<TRpc> where TRpc : IRpc
|
|||
this.Rpc = rpc;
|
||||
}
|
||||
|
||||
#if USE_UNITASK
|
||||
public UniTask<TRpc> Call()
|
||||
{
|
||||
return UniTask.FromResult(Rpc);
|
||||
}
|
||||
#else
|
||||
public Task<TRpc> Call()
|
||||
{
|
||||
return Task.FromResult(Rpc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
{%- for unit in meta.units %}
|
||||
|
|
Loading…
Reference in New Issue