Skip to content

Commit 18f7077

Browse files
committed
{FOLD]
1 parent 7e0e7fb commit 18f7077

1 file changed

Lines changed: 15 additions & 58 deletions

File tree

include/boost/capy/io/write_now.hpp

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,23 @@ class write_now
114114
std::stop_token token_;
115115
bool done_ = false;
116116

117-
// GCC 14 ICE bisection: trivially destructible
118-
// aggregate with full interface
117+
// BISECT: identical to std::suspend_always
118+
// but a different type. If this ICEs, GCC rejects
119+
// ANY non-std awaiter from IoAwaitable branch.
119120
struct erased_io_awaiter
120121
{
121-
void* inner_;
122-
promise_type* p_;
123-
bool (*ready_)(void*);
124-
coro (*suspend_)(
125-
void*, coro,
126-
executor_ref, std::stop_token);
127-
io_result<std::size_t> (*resume_)(void*);
128-
void (*destroy_)(void*);
129-
130-
bool await_ready()
122+
bool await_ready() noexcept
131123
{
132-
return ready_(inner_);
124+
return false;
133125
}
134126

135-
coro await_suspend(coro h)
127+
void await_suspend(
128+
std::coroutine_handle<>) noexcept
136129
{
137-
return suspend_(
138-
inner_, h,
139-
p_->ex_, p_->token_);
140130
}
141131

142-
io_result<std::size_t> await_resume()
132+
void await_resume() noexcept
143133
{
144-
auto r = resume_(inner_);
145-
destroy_(inner_);
146-
inner_ = nullptr;
147-
return r;
148134
}
149135
};
150136

@@ -213,28 +199,10 @@ class write_now
213199
if constexpr (IoAwaitable<decayed>)
214200
{
215201
#if BOOST_CAPY_WRITE_NOW_WORKAROUND
216-
return erased_io_awaiter{
217-
new decayed(std::forward<A>(a)),
218-
this,
219-
+[](void* v) -> bool {
220-
return static_cast<decayed*>(
221-
v)->await_ready();
222-
},
223-
+[](void* v, coro h,
224-
executor_ref ex,
225-
std::stop_token tok) -> coro {
226-
return detail::call_await_suspend(
227-
static_cast<decayed*>(v),
228-
h, ex, tok);
229-
},
230-
+[](void* v)
231-
-> io_result<std::size_t> {
232-
return static_cast<decayed*>(
233-
v)->await_resume();
234-
},
235-
+[](void* v) {
236-
delete static_cast<decayed*>(v);
237-
}};
202+
// BISECT: discard awaitable, return
203+
// suspend_always clone
204+
(void)a;
205+
return erased_io_awaiter{};
238206
#else
239207
struct wrapper
240208
{
@@ -402,20 +370,9 @@ class write_now
402370
op_type
403371
operator()(Buffers buffers)
404372
{
405-
std::size_t const total_size = buffer_size(buffers);
406-
std::size_t total_written = 0;
407-
while(total_written < total_size)
408-
{
409-
auto r = co_await stream_.write_some(
410-
detail::make_consumed(buffers, total_written));
411-
if(r.ec)
412-
{
413-
io_result<std::size_t> result{r.ec, total_written};
414-
co_return result;
415-
}
416-
total_written += r.t1;
417-
}
418-
io_result<std::size_t> result{{}, total_written};
373+
// BISECT: co_await with custom suspend_always clone
374+
co_await stream_.write_some(buffers);
375+
io_result<std::size_t> result{{}, buffer_size(buffers)};
419376
co_return result;
420377
}
421378
#else

0 commit comments

Comments
 (0)