本文整理汇总了Golang中github.com/skydive-project/skydive/topology/graph.Graph.Unlock方法的典型用法代码示例。如果您正苦于以下问题:Golang Graph.Unlock方法的具体用法?Golang Graph.Unlock怎么用?Golang Graph.Unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skydive-project/skydive/topology/graph.Graph
的用法示例。
在下文中一共展示了Graph.Unlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testCleanup
func testCleanup(t *testing.T, g *graph.Graph, cmds []helper.Cmd, names []string) {
// cleanup side on the test
testPassed := false
onChange := func(ws *websocket.Conn) {
g.Lock()
defer g.Unlock()
if !testPassed {
clean := true
for _, name := range names {
n := g.LookupFirstNode(graph.Metadata{"Name": name})
if n != nil {
clean = false
break
}
}
if clean {
testPassed = true
ws.Close()
}
}
}
testTopology(t, g, cmds, onChange)
if !testPassed {
t.Error("test not executed or failed")
}
helper.CleanGraph(g)
}
示例2: processGraphMessage
func processGraphMessage(g *graph.Graph, m []byte) error {
g.Lock()
defer g.Unlock()
var msg shttp.WSMessage
if err := json.Unmarshal(m, &msg); err != nil {
return err
}
if msg.Namespace != "Graph" {
return nil
}
msgType, obj, err := graph.UnmarshalWSMessage(msg)
if err != nil {
return err
}
switch msgType {
case "NodeUpdated":
n := obj.(*graph.Node)
node := g.GetNode(n.ID)
if node != nil {
g.SetMetadata(node, n.Metadata())
}
case "NodeDeleted":
g.DelNode(obj.(*graph.Node))
case "NodeAdded":
n := obj.(*graph.Node)
if g.GetNode(n.ID) == nil {
g.AddNode(n)
}
case "EdgeUpdated":
e := obj.(*graph.Edge)
edge := g.GetEdge(e.ID)
if edge != nil {
g.SetMetadata(edge, e.Metadata())
}
case "EdgeDeleted":
g.DelEdge(obj.(*graph.Edge))
case "EdgeAdded":
e := obj.(*graph.Edge)
if g.GetEdge(e.ID) == nil {
g.AddEdge(e)
}
}
return nil
}
示例3: CleanGraph
func CleanGraph(g *graph.Graph) {
g.Lock()
defer g.Unlock()
hostname, _ := os.Hostname()
g.DelHostGraph(hostname)
}