File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 30
30
#include < exception>
31
31
#include < memory>
32
32
#include < thread>
33
+ #include < type_traits>
33
34
34
35
namespace ssx {
35
36
@@ -64,19 +65,22 @@ class worker_task final : public task_base {
64
65
65
66
void process (ss::alien::instance& alien, ss::shard_id shard) final {
66
67
try {
67
- set_value (alien, shard, _func ());
68
+ if constexpr (std::is_void_v<value_type>) {
69
+ _func ();
70
+ ss::alien::run_on (
71
+ alien, shard, [this ]() { _promise.set_value (); });
72
+ } else {
73
+ auto v = _func ();
74
+ ss::alien::run_on (
75
+ alien, shard, [this , v{std::move (v)}]() mutable {
76
+ _promise.set_value (std::move (v));
77
+ });
78
+ }
68
79
} catch (...) {
69
80
set_exception (alien, shard, std::current_exception ());
70
81
};
71
82
}
72
83
73
- void
74
- set_value (ss::alien::instance& alien, ss::shard_id shard, value_type v) {
75
- ss::alien::run_on (alien, shard, [this , v{std::move (v)}]() mutable {
76
- _promise.set_value (std::move (v));
77
- });
78
- }
79
-
80
84
void set_exception (
81
85
ss::alien::instance& alien,
82
86
ss::shard_id shard,
You can’t perform that action at this time.
0 commit comments