/*
CallWhenTreeStable queues up "Calls" to go out only when the state of the menu is Stable. Stable means that the menu is Ready and has no AwaitingResponses
*/
326468
func (menu *Menu) CallWhenTreeStable(command *Command) {
	menu.Sync.TreeStableQueue = append(menu.Sync.TreeStableQueue, command)
}
393275
func disconnectCallback(n *Node) em.DisconnectCallbackFunc {
	return func() {
		n.Online = false
		n.logger.Info("status", "down")

		if n.disconnectCh != nil {
			n.disconnectCh <- true
		}
	}
}
100060
func (t *tree) parseCall(token item) ast.Node {
	var templateName string
	switch tok := t.next(); tok.typ {
	case itemDotIdent:
		templateName = tok.val
	case itemIdent:
		// this ident could either be {call fully.qualified.name} or attributes.
		switch tok2 := t.next(); tok2.typ {
		case itemDotIdent:
			templateName = tok.val + tok2.val
			for tokn := t.next(); tokn.typ == itemDotIdent; tokn = t.next() {
				templateName += tokn.val
			}
			t.backup()
		default:
			t.backup2(tok)
		}
	default:
		t.backup()
	}
	attrs := t.parseAttrs("name", "data")

	if templateName == "" {
		templateName = attrs["name"]
	}
	if templateName == "" {
		t.errorf("call: template name not found")
	}

	// If it's not a fully qualified template name, apply the namespace or aliases
	if templateName[0] == '.' {
		templateName = t.namespace + templateName
	} else if dot := strings.Index(templateName, "."); dot != -1 {
		if alias, ok := t.aliases[templateName[:dot]]; ok {
			templateName = alias + templateName[dot:]
		}
	}

	var allData = false
	var dataNode ast.Node = nil
	if data, ok := attrs["data"]; ok {
		if data == "all" {
			allData = true
		} else {
			dataNode = t.parseQuotedExpr(data)
		}
	}

	switch tok := t.next(); tok.typ {
	case itemRightDelimEnd:
		return &ast.CallNode{token.pos, templateName, allData, dataNode, nil}
	case itemRightDelim:
		body := t.parseCallParams()
		t.expect(itemLeftDelim, "call")
		t.expect(itemCallEnd, "call")
		t.expect(itemRightDelim, "call")
		return &ast.CallNode{token.pos, templateName, allData, dataNode, body}
	default:
		t.unexpected(tok, "error scanning {call}")
	}
	panic("unreachable")
}
823474
func (f CallerFunc) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) {
	return f(ctx, c)
}
354553
func NewStaticCall(Class node.Node, Call node.Node, ArgumentList *node.ArgumentList) *StaticCall {
	return &StaticCall{
		FreeFloating: nil,
		Class:        Class,
		Call:         Call,
		ArgumentList: ArgumentList,
	}
}
1061824
func (q *Query) endCall() *Call {
	elem := q.callStack[len(q.callStack)-1]
	q.callStack[len(q.callStack)-1] = nil
	q.callStack = q.callStack[:len(q.callStack)-1]
	return elem.call
}
224306
func WithCallWrapper(cw ...CallWrapper) CallOption {
	return func(o *CallOptions) {
		o.CallWrappers = append(o.CallWrappers, cw...)
	}
}
647809
func (menu *Menu) CallWhenReady(command *Command) {
	menu.WaitingResponses = append(menu.WaitingResponses, command)
	menu.Sync.ReadyQueue = append(menu.Sync.ReadyQueue, command)
}
1185680
func (c *Call) Wait() (err error) {
	select {
	case err = <-c.err:
	case <-c.ctx.Done():
		if err = c.ctx.Err(); err == ct.Canceled {
			err = NewError(StatusCanceled, err.Error())
		} else {
			err = NewError(StatusDeadlineExceeded, err.Error())
		}
	}
	//c.n.calls.Release(c)
	return
}
280150
func (e *executor) validateCallArgs(c *pql.Call) error {
	if _, ok := c.Args["ids"]; ok {
		switch v := c.Args["ids"].(type) {
		case []int64, []uint64:
			// noop
		case []interface{}:
			b := make([]int64, len(v))
			for i := range v {
				b[i] = v[i].(int64)
			}
			c.Args["ids"] = b
		default:
			return fmt.Errorf("invalid call.Args[ids]: %s", v)
		}
	}
	return nil
}
269580
func WrapCall(w ...client.CallWrapper) Option {
	return func(o *Options) {
		o.Client.Init(client.WrapCall(w...))
	}
}
366785
func (c *Controller) OnFinalShutdown(fn func() error) {
	c.instance.onFinalShutdown = append(c.instance.onFinalShutdown, fn)
}
805300
func Call(o dbus.BusObject) (*Node, error) {
	var xmldata string
	var node Node

	err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata)
	if err != nil {
		return nil, err
	}
	err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node)
	if err != nil {
		return nil, err
	}
	if node.Name == "" {
		node.Name = string(o.Path())
	}
	return &node, nil
}
1104897
func (p *tchannelPeer) Call(ctx context.Context, req *transport.Request) (*transport.Response, error) {
	root := p.transport.ch.RootPeers()
	tp := root.GetOrAdd(p.HostPort())
	return callWithPeer(ctx, req, tp, p.transport.headerCase)
}
255783
func (v *evalVisitor) callHelper(name string, helper reflect.Value, node *ast.Expression) interface{} {
	result := v.callFunc(name, helper, v.helperOptions(node))
	if !result.IsValid() {
		return nil
	}

	// @todo We maybe want to ensure here that helper returned a string or a SafeString
	return result.Interface()
}
142698
func (e *Endpoint) CallsMapPathLocked() string {
	return bpf.LocalMapPath(loader.CallsMapName, e.ID)
}
352221
func (self *_object) isCall() bool {
	switch fn := self.value.(type) {
	case _nativeFunctionObject:
		return fn.call != nil
	case _bindFunctionObject:
		return true
	case _nodeFunctionObject:
		return true
	}
	return false
}