summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-runners/context.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2025-03-09 17:47:56 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2025-03-10 01:59:49 +0100
commit3ac1ee16f377d31a0fb80c8dae28b6239ac4229e (patch)
treef61faa581feaaeaba2542b9f2b8234a590684413 /vendor/codeberg.org/gruf/go-runners/context.go
parent[chore] update URLs to forked source (diff)
downloadgotosocial-3ac1ee16f377d31a0fb80c8dae28b6239ac4229e.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-runners/context.go')
-rw-r--r--vendor/codeberg.org/gruf/go-runners/context.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/vendor/codeberg.org/gruf/go-runners/context.go b/vendor/codeberg.org/gruf/go-runners/context.go
deleted file mode 100644
index 12f7f1a10..000000000
--- a/vendor/codeberg.org/gruf/go-runners/context.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package runners
-
-import (
- "context"
- "time"
-)
-
-// closedctx is an always closed context.
-var closedctx = func() context.Context {
- ctx := make(chan struct{})
- close(ctx)
- return CancelCtx(ctx)
-}()
-
-// Closed returns an always closed context.
-func Closed() context.Context {
- return closedctx
-}
-
-// CtxWithCancel returns a new context.Context impl with cancel.
-func CtxWithCancel() (context.Context, context.CancelFunc) {
- ctx := make(chan struct{})
- cncl := func() { close(ctx) }
- return CancelCtx(ctx), cncl
-}
-
-// CancelCtx is the simplest possible cancellable context.
-type CancelCtx (<-chan struct{})
-
-func (CancelCtx) Deadline() (time.Time, bool) {
- return time.Time{}, false
-}
-
-func (ctx CancelCtx) Done() <-chan struct{} {
- return ctx
-}
-
-func (ctx CancelCtx) Err() error {
- select {
- case <-ctx:
- return context.Canceled
- default:
- return nil
- }
-}
-
-func (CancelCtx) Value(key interface{}) interface{} {
- return nil
-}
-
-func (ctx CancelCtx) String() string {
- var state string
- select {
- case <-ctx:
- state = "closed"
- default:
- state = "open"
- }
- return "CancelCtx{state:" + state + "}"
-}
-
-func (ctx CancelCtx) GoString() string {
- return "runners." + ctx.String()
-}