xio: Add Reader/Writer/... interfaces - io analogs that add support for contexts
In many cases IO needs to be able to be canceled. For example in WCFS filesystem I need to cancel handling sysread(/head/watch) when FUSE INTERRUPT request comes in [1,2,3]. The READ handler for /head/watch inside WCFS is interally implemented via io.Pipe which does not provide read/write cancellattion besides "destructive" close. Standard Go answer for cancellations is via contexts. So as a first step let's add corresponding interfaces - xio.Reader, xio.Writer etc - that are io analogs that add support for contexts. For compatibility with legacy code that work with only io.X (e.g. only with io.Reader), in spirit of [4], add BindCtx which binds xio.X instance with context and converts it into io.X. Add WithCtx - corresponding inverse operation that converts io.X back into xio.X and for general io.X adds cancellation handling on a best-effort basis. [1] wendelin.core@b17aeb8c [2] wendelin.core@f05271b1 [3] wendelin.core@5ba816da [4] https://github.com/golang/go/issues/20280 [5] https://github.com/golang/go/issues/16522
Showing
xio/xio_test.go
0 → 100644
-
mentioned in commit go-fuse@2275cf72
-
mentioned in commit go-fuse@79855bd6
-
mentioned in commit go-fuse@c246ae51
-
mentioned in merge request nexedi/nxdtest!7 (closed)
-
mentioned in commit wendelin.core@ad766f75
-
mentioned in commit wendelin.core@fa9be6d6
-
mentioned in commit wendelin.core@737033df
-
mentioned in commit levin.zimmermann/wendelin.core@c7c3b82a
Please register or sign in to comment