add HookExitCb for OnExitCb

This commit is contained in:
cuu
2023-01-16 12:55:12 +00:00
parent ef19017718
commit 0e62938403
13 changed files with 265 additions and 125 deletions

62
sysgo/UI/page_stack.go Normal file
View File

@@ -0,0 +1,62 @@
package UI
import (
"sync"
)
type element struct {
data interface{}
next *element
}
type PageStack struct {
lock *sync.Mutex
head *element
Size int
}
func (stk *PageStack) Push(data interface{}) {
stk.lock.Lock()
element := new(element)
element.data = data
temp := stk.head
element.next = temp
stk.head = element
stk.Size++
stk.lock.Unlock()
}
func (stk *PageStack) Pop() interface{} {
if stk.head == nil {
return nil
}
stk.lock.Lock()
r := stk.head.data
stk.head = stk.head.next
stk.Size--
stk.lock.Unlock()
return r
}
func (stk *PageStack) Length() int {
return stk.Size
}
func (stk *PageStack) Last() interface{} {
idx := stk.Length() - 1
if idx < 0 {
return nil
} else {
return stk.head.data
}
}
func NewPageStack() *PageStack {
stk := new(PageStack)
stk.lock = &sync.Mutex{}
return stk
}