本文整理匯總了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)
}