Documentation ¶
Index ¶
- Constants
- Variables
- type Event
- func (ev *Event) Assign(base *EventBase, fd int, events uint32, ...)
- func (ev *Event) Attach(timeout time.Duration) error
- func (ev *Event) Base() *EventBase
- func (ev *Event) Detach() error
- func (ev *Event) Events() uint32
- func (ev *Event) Fd() int
- func (ev *Event) Priority() eventPriority
- func (ev *Event) SetPriority(priority eventPriority)
- func (ev *Event) Timeout() time.Duration
- type EventBase
Constants ¶
const ( // EvRead is readable event. EvRead = 1 << iota // EvWrite is writable event. EvWrite = 1 << iota // EvTimeout is timeout event. EvTimeout = 1 << iota // EvPersist is persistent behavior option. EvPersist = 1 << iota // EvET is edge-triggered behavior option. EvET = 1 << iota // EvLoopOnce is the flag to control event base loop just once. EvLoopOnce = 001 // EvLoopNoblock is the flag to control event base loop not block. EvLoopNoblock = 002 // HPri is the high priority. HPri eventPriority = 0b00 // MPri is the middle priority. MPri eventPriority = 0b01 // LPri is the low priority. LPri eventPriority = 0b10 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is the event to watch.
func New ¶
func New(base *EventBase, fd int, events uint32, callback func(fd int, events uint32, arg interface{}), arg interface{}) *Event
New creates a new event with default priority MPri.
func NewTicker ¶ added in v1.2.2
func NewTicker(base *EventBase, callback func(fd int, events uint32, arg interface{}), arg interface{}) *Event
NewTicker creates a new ticker event.
func NewTimer ¶ added in v1.2.2
func NewTimer(base *EventBase, callback func(fd int, events uint32, arg interface{}), arg interface{}) *Event
NewTimer creates a new timer event.
func (*Event) Assign ¶ added in v1.2.2
func (ev *Event) Assign(base *EventBase, fd int, events uint32, callback func(fd int, events uint32, arg interface{}), arg interface{}, priority eventPriority)
Assign assigns the event. It is used to reuse the event. The event must be detached before it is assigned.
func (*Event) Attach ¶ added in v1.2.4
Attach adds the event to the event base. Timeout is the timeout of the event. Default is 0, which means no timeout. But if EvTimeout is set in the event, the 0 represents expired immediately.
func (*Event) Detach ¶ added in v1.2.4
Detach deletes the event from the event base. The event will not be triggered after it is detached.
func (*Event) Priority ¶ added in v1.2.4
func (ev *Event) Priority() eventPriority
Priority returns the priority of the event.
func (*Event) SetPriority ¶ added in v1.2.2
func (ev *Event) SetPriority(priority eventPriority)
SetPriority sets the priority of the event.
type EventBase ¶
type EventBase struct {
// contains filtered or unexported fields
}
EventBase is the base of all events.
func (*EventBase) Loop ¶ added in v1.2.4
Loop loops events. Flags is the flags to control the loop behavior. Flags can be EvLoopOnce or EvLoopNoblock or both. If EvLoopOnce is set, the loop will just loop once. If EvLoopNoblock is set, the loop will not block.