func (c *Caster) Close() (ok bool) {
	select {
	case <-c.done:
		return false
	case c.op <- operation{
		operator: opClose,
	}:
		return true
	}
}
Close closes current caster and all subscriber channels. Ok value indicates whether the operation
is performed or not. When current caster is closed, it stops receiving further operations and the
operation won't be performed.
package caster
import (
	"context"
)
type operator int
const (
	opPub operator = iota
	opTryPub
	opSub
	opUnsub
	opClose
)
type operation struct {
	operator operator
	operand  interface{}
}
type subInfo struct {
	ch  chan interface{}
	ctx context.Context
}
type Caster struct {
	done chan struct{}
	op   chan operation
}
func New(ctx context.Context) *Caster {
	if ctx == nil {
		ctx = context.Background()
	}
	c := &Caster{
		done: make(chan struct{}),
		op:   make(chan operation),
	}
	go func() {
		subs := map[chan interface{}]context.Context{}
		checkCtx := func(sCh chan interface{}, sCtx context.Context) bool {
			select {
			case <-sCtx.Done():
				delete(subs, sCh)
				close(sCh)
				return false
			default:
				return true
			}
		}
	topLoop:
		for {
			select {
			case <-ctx.Done():
				break topLoop
			case o := <-c.op:
				switch o.operator {
				case opPub:
					for sCh, sCtx := range subs {
						if !checkCtx(sCh, sCtx) {
							continue
						}
						select {
						case sCh <- o.operand:
						}
					}
				case opTryPub:
					for sCh, sCtx := range subs {
						if !checkCtx(sCh, sCtx) {
							continue
						}
						select {
						case sCh <- o.operand:
						default:
						}
					}
				case opSub:
					sIn := o.operand.(subInfo)
					subs[sIn.ch] = sIn.ctx
				case opUnsub:
					sCh := o.operand.(chan interface{})
					delete(subs, sCh)
					close(sCh)
				case opClose:
					break topLoop
				}
			}
		}
		for sCh := range subs {
			close(sCh)
		}
		close(c.done)
	}()
	return c
}
func (c *Caster) Done() <-chan struct{} {
	return c.done
}