Skip to content

Commit

Permalink
kqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-zhongliang committed Oct 4, 2023
1 parent c2a75bd commit b783a5b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
EvRead = 1 << iota
// EvWrite is writable event.
EvWrite = 1 << iota
// EvTimeout is timeout event
// EvTimeout is timeout event.
EvTimeout = 1 << iota
// EvClosed is closed event.
EvClosed = 1 << iota
Expand Down Expand Up @@ -174,8 +174,8 @@ type EventBase struct {
activeEvLists []*list
// eventHeap is the min heap of timeout events.
evHeap *eventHeap
// nowCache is the cache of now time.
nowCache time.Time
// nowTimeCache is the cache of now time.
nowTimeCache time.Time
}

// NewBase creates a new event base.
Expand All @@ -190,7 +190,7 @@ func NewBase() (*EventBase, error) {
evList: newList(),
activeEvLists: []*list{newList(), newList(), newList()},
evHeap: new(eventHeap),
nowCache: time.Time{},
nowTimeCache: time.Time{},
}, nil
}

Expand Down Expand Up @@ -353,16 +353,16 @@ func (bs *EventBase) eventQueueRemove(ev *Event, which int) {
}

func (bs *EventBase) now() time.Time {
if !bs.nowCache.IsZero() {
return bs.nowCache
if !bs.nowTimeCache.IsZero() {
return bs.nowTimeCache
}
return time.Now()
}

func (bs *EventBase) updateTimeCache() {
bs.nowCache = time.Now()
bs.nowTimeCache = time.Now()
}

func (bs *EventBase) clearTimeCache() {
bs.nowCache = time.Time{}
bs.nowTimeCache = time.Time{}
}

0 comments on commit b783a5b

Please sign in to comment.