3 ms·
> So why is write not doing an implicit drain? Well it's a massive API oversight and I'm not exactly sure how it happened. Separating these two operations allo
by kd5bjo 7y ago
> So why is write not doing an implicit drain? Well it's a massive API oversight and I'm not exactly sure how it happened.
Separating these two operations allows code to use multiple write() calls to build up a single record atomically before yielding control to the system, where some other task might also write to the same stream. This reasoning is only valid if the program is running on a single thread, but that’s a reasonable architecture decision for many programs.
- heftig 7y agoCouldn't you have an API with a write() return value that you can await to trigger a drain(), but which you can also leave unused, in which case it acts like the current write()?
- PudgePacket 7y agoNot a super great argument. It would be easy to just build up the data to be written then write it in 1 call, while at the same time preventing people from being able to use it incorrectly at all.