本文整理匯總了Golang中github.com/BurntSushi/xgbutil.XUtil.Evqueue方法的典型用法代碼示例。如果您正苦於以下問題:Golang XUtil.Evqueue方法的具體用法?Golang XUtil.Evqueue怎麽用?Golang XUtil.Evqueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/xgbutil.XUtil
的用法示例。
在下文中一共展示了XUtil.Evqueue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Dequeue
// Dequeue pops an event/error from the queue and returns it.
// The queue item is unwrapped and returned as multiple return values.
// Only one of the return values can be nil.
func Dequeue(xu *xgbutil.XUtil) (xgb.Event, xgb.Error) {
xu.EvqueueLck.Lock()
defer xu.EvqueueLck.Unlock()
everr := xu.Evqueue[0]
xu.Evqueue = xu.Evqueue[1:]
return everr.Event, everr.Err
}
示例2: Enqueue
// Enqueue queues up an event read from X.
// Note that an event read may return an error, in which case, this queue
// entry will be an error and not an event.
//
// ev, err := XUtilValue.Conn().WaitForEvent()
// xevent.Enqueue(XUtilValue, ev, err)
//
// You probably shouldn't have to enqueue events yourself. This is done
// automatically if you're using xevent.Main{Ping} and/or xevent.Read.
func Enqueue(xu *xgbutil.XUtil, ev xgb.Event, err xgb.Error) {
xu.EvqueueLck.Lock()
defer xu.EvqueueLck.Unlock()
xu.Evqueue = append(xu.Evqueue, xgbutil.EventOrError{
Event: ev,
Err: err,
})
}
示例3: DequeueAt
// DequeueAt removes a particular item from the queue.
// This is primarily useful when attempting to compress events.
func DequeueAt(xu *xgbutil.XUtil, i int) {
xu.EvqueueLck.Lock()
defer xu.EvqueueLck.Unlock()
xu.Evqueue = append(xu.Evqueue[:i], xu.Evqueue[i+1:]...)
}