mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
ircd::ios: Add no-op synchronous defer overload; use w/ this_ctx::yield().
This commit is contained in:
parent
f48182404f
commit
7af8e5774c
3 changed files with 63 additions and 18 deletions
|
@ -77,6 +77,7 @@ struct ircd::ios::dispatch
|
|||
{
|
||||
dispatch(descriptor &, std::function<void ()>);
|
||||
dispatch(descriptor &, synchronous_t, const std::function<void ()> &);
|
||||
dispatch(descriptor &, synchronous_t);
|
||||
dispatch(std::function<void ()>);
|
||||
dispatch(synchronous_t, const std::function<void ()> &);
|
||||
};
|
||||
|
@ -85,6 +86,7 @@ struct ircd::ios::defer
|
|||
{
|
||||
defer(descriptor &, std::function<void ()>);
|
||||
defer(descriptor &, synchronous_t, const std::function<void ()> &);
|
||||
defer(descriptor &, synchronous_t);
|
||||
defer(std::function<void ()>);
|
||||
defer(synchronous_t, const std::function<void ()> &);
|
||||
};
|
||||
|
@ -93,6 +95,7 @@ struct ircd::ios::post
|
|||
{
|
||||
post(descriptor &, std::function<void ()>);
|
||||
post(descriptor &, synchronous_t, const std::function<void ()> &);
|
||||
post(descriptor &, synchronous_t);
|
||||
post(std::function<void ()>);
|
||||
post(synchronous_t, const std::function<void ()> &);
|
||||
};
|
||||
|
|
15
ircd/ctx.cc
15
ircd/ctx.cc
|
@ -638,19 +638,10 @@ ircd::ctx::this_ctx::yield()
|
|||
"ircd::ctx courtesy yield"
|
||||
};
|
||||
|
||||
bool done(false);
|
||||
const auto restore([&done, &me(cur())]
|
||||
ircd::defer
|
||||
{
|
||||
done = true;
|
||||
notify(me);
|
||||
});
|
||||
|
||||
// All spurious notifications are ignored until `done`
|
||||
ircd::defer(descriptor, restore); do
|
||||
{
|
||||
wait();
|
||||
}
|
||||
while(!done);
|
||||
descriptor, ios::synchronous
|
||||
};
|
||||
}
|
||||
|
||||
ulong
|
||||
|
|
63
ircd/ios.cc
63
ircd/ios.cc
|
@ -290,14 +290,31 @@ ircd::ios::dispatch_desc
|
|||
};
|
||||
|
||||
ircd::ios::dispatch::dispatch(std::function<void ()> function)
|
||||
:dispatch
|
||||
{
|
||||
dispatch_desc, std::move(function)
|
||||
}
|
||||
{
|
||||
dispatch(dispatch_desc, std::move(function));
|
||||
}
|
||||
|
||||
ircd::ios::dispatch::dispatch(synchronous_t,
|
||||
const std::function<void ()> &function)
|
||||
:dispatch
|
||||
{
|
||||
dispatch_desc, synchronous, std::move(function)
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::ios::dispatch::dispatch(descriptor &descriptor,
|
||||
synchronous_t)
|
||||
:dispatch
|
||||
{
|
||||
dispatch_desc, synchronous, []
|
||||
{
|
||||
}
|
||||
}
|
||||
{
|
||||
dispatch(dispatch_desc, synchronous, std::move(function));
|
||||
}
|
||||
|
||||
ircd::ios::dispatch::dispatch(descriptor &descriptor,
|
||||
|
@ -337,14 +354,31 @@ ircd::ios::defer_desc
|
|||
};
|
||||
|
||||
ircd::ios::defer::defer(std::function<void ()> function)
|
||||
:defer
|
||||
{
|
||||
defer_desc, std::move(function)
|
||||
}
|
||||
{
|
||||
defer(defer_desc, std::move(function));
|
||||
}
|
||||
|
||||
ircd::ios::defer::defer(synchronous_t,
|
||||
const std::function<void ()> &function)
|
||||
:defer
|
||||
{
|
||||
defer_desc, synchronous, function
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::ios::defer::defer(descriptor &descriptor,
|
||||
synchronous_t)
|
||||
:defer
|
||||
{
|
||||
defer_desc, synchronous, []
|
||||
{
|
||||
}
|
||||
}
|
||||
{
|
||||
defer(defer_desc, synchronous, function);
|
||||
}
|
||||
|
||||
ircd::ios::defer::defer(descriptor &descriptor,
|
||||
|
@ -384,14 +418,31 @@ ircd::ios::post_desc
|
|||
};
|
||||
|
||||
ircd::ios::post::post(std::function<void ()> function)
|
||||
:post
|
||||
{
|
||||
post_desc, std::move(function)
|
||||
}
|
||||
{
|
||||
post(post_desc, std::move(function));
|
||||
}
|
||||
|
||||
ircd::ios::post::post(synchronous_t,
|
||||
const std::function<void ()> &function)
|
||||
:post
|
||||
{
|
||||
post_desc, synchronous, function
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::ios::post::post(descriptor &descriptor,
|
||||
synchronous_t)
|
||||
:post
|
||||
{
|
||||
descriptor, synchronous, []
|
||||
{
|
||||
}
|
||||
}
|
||||
{
|
||||
post(post_desc, synchronous, function);
|
||||
}
|
||||
|
||||
ircd::ios::post::post(descriptor &descriptor,
|
||||
|
|
Loading…
Add table
Reference in a new issue