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.
To make this feasible, need to switch to a proper event loop (e.g.:
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
- When pasting, also write to the fd with
Need to write an adaptor that wraps sendfile into a Future.
Writing to files async is not really feasible, so writing to the file will always happen on a separate thread.