You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
394 B
27 lines
394 B
3 years ago
|
package timed_task
|
||
|
|
||
|
type TimeTask struct {
|
||
|
delMgoChatChan chan bool
|
||
|
}
|
||
|
|
||
|
var timeTask TimeTask
|
||
|
|
||
|
func GetInstance() *TimeTask {
|
||
|
if timeTask.delMgoChatChan == nil {
|
||
|
timeTask.delMgoChatChan = make(chan bool)
|
||
|
go func() {
|
||
|
timeTask.delMgoChatChan <- true
|
||
|
}()
|
||
|
}
|
||
|
return &timeTask
|
||
|
}
|
||
|
|
||
|
func (t *TimeTask) Run() {
|
||
|
for {
|
||
|
select {
|
||
|
case <-t.delMgoChatChan:
|
||
|
t.timedDeleteUserChat()
|
||
|
}
|
||
|
}
|
||
|
}
|