mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-09-27 05:35:57 +08:00
16 lines
275 B
Go
16 lines
275 B
Go
package util
|
|
|
|
import "context"
|
|
|
|
type Promise[T any] struct {
|
|
context.Context
|
|
context.CancelCauseFunc
|
|
Value T
|
|
}
|
|
|
|
func NewPromise[T any](v T) *Promise[T] {
|
|
p := &Promise[T]{Value: v}
|
|
p.Context, p.CancelCauseFunc = context.WithCancelCause(context.Background())
|
|
return p
|
|
}
|