~whynothugo/shotman#8: 
Stop doing blocking IO

There's a lot of blocking IO happening. This was mostly a hack to get things working, but not idea, since I spawn a new thread for each file/paste.

Status
REPORTED
Submitter
~whynothugo
Assigned to
No-one
Submitted
2 years ago
Updated
6 months ago
Labels
No labels applied.

~whynothugo 2 years ago

To make this feasible, need to switch to a proper event loop (e.g.: calloop?).

~whynothugo 2 years ago

So far the best approach seems to be:

  • Create a file descriptor with memfd.
  • Encode the png into it, then seal it.
  • Write to the file with sendfile.
  • When pasting, also write to the fd with sendfile.

Need to write an adaptor that wraps sendfile into a Future.

~whynothugo 1 year, 10 months ago

Writing to files async is not really feasible, so writing to the file will always happen on a separate thread.

~whynothugo 6 months ago

File writes are always blocking on Linux (apparently it's a POSIX thing).

I can spawn a child that does writes to a file. I need to handle the memfd to the child (e.g.: don't stream data to the child, that would be wasteful). Communicating with the child can be entirely non blocking.

Register here or Log in to comment, or comment via email.