Commit f615b0e2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d293272d
......@@ -58,6 +58,8 @@ func Canceled(err error) bool {
//
// func myfunc(ctx, ...) {
// defer xcontext.WhenDone(ctx, func() { ... })()
//
// XXX -> use WithCloseOnErrCancel instead?
func WhenDone(ctx context.Context, f func()) func() {
done := make(chan struct{})
go func() {
......
// Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Copyright (C) 2017-2021 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -54,6 +54,8 @@ func EOFok(err error) error {
// defer xio.CloseWhenDone(ctx, c)()
//
// The error - if c.Close() returns with any - is logged.
//
// XXX -> use xcontext.WithCloseOnErrCancel instead?
func CloseWhenDone(ctx context.Context, c io.Closer) func() {
return xcontext.WhenDone(ctx, func() {
err := c.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment