mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-27 14:05:50 +00:00
committed by
Nik Bougalis
parent
1dc3acb071
commit
fa0a61b5d7
@@ -78,10 +78,15 @@ private:
|
|||||||
struct YieldStrategy
|
struct YieldStrategy
|
||||||
{
|
{
|
||||||
enum class Streaming {no, yes};
|
enum class Streaming {no, yes};
|
||||||
|
enum class UseCoroutines {no, yes};
|
||||||
|
|
||||||
/** Is the data streamed, or generated monolithically? */
|
/** Is the data streamed, or generated monolithically? */
|
||||||
Streaming streaming = Streaming::no;
|
Streaming streaming = Streaming::no;
|
||||||
|
|
||||||
|
/** Are results generated in a coroutine? If this is no, then the code can
|
||||||
|
never yield. */
|
||||||
|
UseCoroutines useCoroutines = UseCoroutines::no;
|
||||||
|
|
||||||
/** How many bytes do we emit before yielding? 0 means "never yield due to
|
/** How many bytes do we emit before yielding? 0 means "never yield due to
|
||||||
number of bytes sent". */
|
number of bytes sent". */
|
||||||
std::size_t byteYieldCount = 0;
|
std::size_t byteYieldCount = 0;
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ YieldStrategy makeYieldStrategy (Section const& s)
|
|||||||
ys.streaming = get<bool> (s, "streaming") ?
|
ys.streaming = get<bool> (s, "streaming") ?
|
||||||
YieldStrategy::Streaming::yes :
|
YieldStrategy::Streaming::yes :
|
||||||
YieldStrategy::Streaming::no;
|
YieldStrategy::Streaming::no;
|
||||||
|
ys.useCoroutines = get<bool> (s, "use_coroutines") ?
|
||||||
|
YieldStrategy::UseCoroutines::yes :
|
||||||
|
YieldStrategy::UseCoroutines::no;
|
||||||
ys.byteYieldCount = get<std::size_t> (s, "byte_yield_count");
|
ys.byteYieldCount = get<std::size_t> (s, "byte_yield_count");
|
||||||
ys.accountYieldCount = get<std::size_t> (s, "account_yield_count");
|
ys.accountYieldCount = get<std::size_t> (s, "account_yield_count");
|
||||||
ys.transactionYieldCount = get<std::size_t> (s, "transaction_yield_count");
|
ys.transactionYieldCount = get<std::size_t> (s, "transaction_yield_count");
|
||||||
|
|||||||
@@ -180,12 +180,24 @@ ServerHandlerImp::onRequest (HTTP::Session& session)
|
|||||||
|
|
||||||
auto detach = session.detach();
|
auto detach = session.detach();
|
||||||
|
|
||||||
|
if (setup_.yieldStrategy.useCoroutines ==
|
||||||
|
RPC::YieldStrategy::UseCoroutines::yes)
|
||||||
|
{
|
||||||
RPC::SuspendCallback suspend (
|
RPC::SuspendCallback suspend (
|
||||||
[this, detach] (RPC::Suspend const& suspend) {
|
[this, detach] (RPC::Suspend const& suspend) {
|
||||||
processSession (detach, suspend);
|
processSession (detach, suspend);
|
||||||
});
|
});
|
||||||
RPC::Coroutine coroutine (suspend);
|
RPC::Coroutine coroutine (suspend);
|
||||||
coroutine.run();
|
coroutine.run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getApp().getJobQueue().addJob (
|
||||||
|
jtCLIENT, "RPC-Client",
|
||||||
|
[=] (Job&) {
|
||||||
|
processSession (detach, RPC::Suspend());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user