forked from AsunaU2/GoCGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT01_Simple.go
More file actions
57 lines (43 loc) · 1004 Bytes
/
T01_Simple.go
File metadata and controls
57 lines (43 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//go:build T01
// +build T01
package main
import (
"fmt"
"time"
)
// MyNode1 implements a node that sleeps for 1 second
type MyNode1 struct {
BaseGElement
}
// Run executes the node logic
func (n *MyNode1) Run() *CStatus {
fmt.Printf("%s: sleep 1s.\n", n.GetName())
time.Sleep(1 * time.Second)
return NewCStatus()
}
// MyNode2 implements a node that sleeps for 2 seconds
type MyNode2 struct {
BaseGElement
}
func (n *MyNode2) Run() *CStatus {
fmt.Printf("%s: sleep 2s.\n", n.GetName())
time.Sleep(2 * time.Second)
return NewCStatus()
}
func tutorialSimple() {
var a, b, c, d GElement
pipeline := Factory.Create()
a = &MyNode1{}
pipeline.RegisterGElement(a, []GElement{}, "nodeA")
b = &MyNode2{}
pipeline.RegisterGElement(b, []GElement{a}, "nodeB")
c = &MyNode1{}
pipeline.RegisterGElement(c, []GElement{a}, "nodeC")
d = &MyNode2{}
pipeline.RegisterGElement(d, []GElement{b, c}, "nodeD")
pipeline.Process(1)
Factory.Remove(pipeline)
}
func main() {
tutorialSimple()
}