本文整理汇总了Golang中github.com/jpoirier/gortlsdr.Context.CancelAsync方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.CancelAsync方法的具体用法?Golang Context.CancelAsync怎么用?Golang Context.CancelAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jpoirier/gortlsdr.Context
的用法示例。
在下文中一共展示了Context.CancelAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sig_abort
func sig_abort(dev *rtl.Context) {
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT)
<-ch
_ = dev.CancelAsync()
dev.Close()
os.Exit(0)
}
示例2: async_stop
func async_stop(dev *rtl.Context, c chan bool) {
<-c // async-read done signal
log.Println("Received async-read done, calling CancelAsync\n")
if status := dev.CancelAsync(); status != rtl.Success {
log.Println("CancelAsync failed\n")
} else {
log.Println("CancelAsync successful\n")
}
os.Exit(0)
}
示例3: sig_abort
func sig_abort(dev *rtl.Context) {
//Make a Channel of os.Signal objects
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT)
//Wait for the Channel to return something. Discarding
//the retruned value since we know it's SIGINT
<-ch
log.Printf("SIGINT signal received!\n")
//This code will execute after SIGINT is returned
_ = dev.CancelAsync()
dev.Close()
os.Exit(0)
}