本文整理匯總了Golang中Time.Ticker.C方法的典型用法代碼示例。如果您正苦於以下問題:Golang Ticker.C方法的具體用法?Golang Ticker.C怎麽用?Golang Ticker.C使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Time.Ticker
的用法示例。
在下文中一共展示了Ticker.C方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestRetire
func (s *S) TestRetire(c *gocheck.C) {
defer func() {
if r := recover(); !c.Failed() && r == nil {
c.Errorf("Should panic in ping, but did not!")
}
}()
Open("127.0.0.1:27017", "tsuru_storage_test")
sess := conn["127.0.0.1:27017"]
sess.used = sess.used.Add(-1 * 2 * period)
conn["127.0.0.1:27017"] = sess
var ticker time.Ticker
ch := make(chan time.Time, 1)
ticker.C = ch
ch <- time.Now()
var wg sync.WaitGroup
wg.Add(1)
go func() {
retire(&ticker)
wg.Done()
}()
close(ch)
wg.Wait()
_, ok := conn["127.0.0.1:27017"]
c.Check(ok, gocheck.Equals, false)
sess.s.Ping()
}
示例2: TestRetire
func (s *S) TestRetire(c *check.C) {
log.Println("--> start [TestRetire]")
defer func() {
if r := recover(); !c.Failed() && r == nil {
c.Errorf("Should panic in ping, but did not!")
}
}()
Open(addr, bkt)
ky := strings.Join(addr, "::")
sess := conn[ky]
sess.used = sess.used.Add(-1 * 2 * period)
conn[ky] = sess
var ticker time.Ticker
ch := make(chan time.Time, 1)
ticker.C = ch
ch <- time.Now()
var wg sync.WaitGroup
wg.Add(1)
go func() {
retire(&ticker)
wg.Done()
}()
close(ch)
wg.Wait()
_, ok := conn[ky]
c.Check(ok, check.Equals, false)
sess1 := conn[ky]
sess1.s.Ping()
log.Println("--> end [TestOpenReconnects]")
}