github.com/iotexproject/iotex-core@v1.14.1-rc1/pkg/routine/options.go (about) 1 // Copyright (c) 2018 IoTeX 2 // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability 3 // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. 4 // This source code is governed by Apache License 2.0 that can be found in the LICENSE file. 5 6 package routine 7 8 import ( 9 "github.com/facebookgo/clock" 10 ) 11 12 type clockOption struct{ c clock.Clock } 13 14 // WithClock set a clock to a task. 15 func WithClock(c clock.Clock) interface { 16 RecurringTaskOption 17 DelayTaskOption 18 } { 19 return &clockOption{c} 20 } 21 22 func (o *clockOption) SetRecurringTaskOption(r *RecurringTask) { 23 r.clock = o.c 24 } 25 26 func (o *clockOption) SetDelayTaskOption(d *DelayTask) { 27 d.clock = o.c 28 }