RussellLuo / timingwheel

Golang implementation of Hierarchical Timing Wheels.
MIT License
657 stars 123 forks source link

为什么用这个b unsafe.Pointer 而不用这个*bucket #47

Open EddieChan1993 opened 1 year ago

EddieChan1993 commented 1 year ago
// Timer represents a single event. When the Timer expires, the given
// task will be executed.
type Timer struct {
   expiration int64 // in milliseconds
   task       func()

   // The bucket that holds the list to which this timer's element belongs.
   //
   // NOTE: This field may be updated and read concurrently,
   // through Timer.Stop() and Bucket.Flush().
   b unsafe.Pointer // type: *bucket

   // The timer's element.
   element *list.Element
}

有什么考究吗?