mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-30 01:02:25 -05:00
add gruf worker pool
This commit is contained in:
parent
2f57eb5ece
commit
e08c0e55ee
9 changed files with 503 additions and 0 deletions
36
vendor/codeberg.org/gruf/go-runners/context.go
generated
vendored
Normal file
36
vendor/codeberg.org/gruf/go-runners/context.go
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package runners
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ContextWithCancel returns a new context.Context impl with cancel.
|
||||
func ContextWithCancel() (context.Context, context.CancelFunc) {
|
||||
ctx := make(cancelctx)
|
||||
return ctx, func() { close(ctx) }
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue