草庐IT

dispatch_cancel

全部标签

ios - dispatch_queue_t 中的 "t"代表什么?

我似乎无法从Apple的GCD文档中找出dispatch_queue_t中的“t”代表什么。起初我以为是“线程”,但看了之后thisquestion我认为这意味着typedef。如果是这样,那么dispatch_queue_t的typedef是什么? 最佳答案 它代表“类型”。如果文档没有指定dispatch_queue_t是什么typedef,那么它就是一个不透明的类型:你不应该知道,因为它是一个实现细节(不是部分API规范)。 关于ios-dispatch_queue_t中的"t"代

ios - 无形的执行顺序(dispatch_semaphore_t、dispatch_group_async)以及它们与不同调度队列类型的结合使用

我只是在晚上花了一些时间来研究GCD,尤其是dispatch_semaphore_t,因为我从未使用过它。从来不需要。所以我写了下面的作为测试:-(void)viewDidLoad{UIView*firstView=[[UIViewalloc]initWithFrame:(CGRect){{0,0},self.view.frame.size.width/4,self.view.frame.size.width/5}];firstView.backgroundColor=[UIColorpurpleColor];[self.viewaddSubview:firstView];dispat

ios - dispatch_queue_set_specific 与获取当前队列

我试图弄清楚这两者之间的区别和用法:staticvoid*myFirstQueue="firstThread";dispatch_queue_tfirstQueue=dispatch_queue_create("com.year.new.happy",DISPATCH_QUEUE_CONCURRENT);dispatch_queue_set_specific(firstQueue,myFirstQueue,(void*)myFirstQueue,NULL);问题#1这有什么区别:dispatch_sync(firstQueue,^{if(dispatch_get_specific(my

ios - 通过示例了解何时使用 dispatch_get_main_queue 和 requiresMainQueueSetup

前一段时间我在这里问过类似的问题:DifferencerequiresMainQueueSetupanddispatch_get_main_queue?我今天回过头来发现我还没有完全掌握它。当我们为iOS编写ReactNative模块时,iOS端有dispatch_get_main_queue并且react-native需要requiresMainQueueSetup。对于以下包和用例,应该如何使用其中的哪一个?asq-react-native-device-导出包ID等常量的包asq-react-native-sensors-允许从设备陀螺仪和其他传感器订阅和接收数据的包asq-re

ios - corebluetooth 读取 RSSI 错误 :The operation was cancelled

我正在使用Corebluetooth框架开发一个应用程序,并连接到BLE设备以获取RSSI值。我设置了一个定时读取RSSI的函数,定时器代码如下NSTimer*timer;timer=[NSTimerscheduledTimerWithTimeInterval:1.2ftarget:selfselector:@selector(detectRSSI)userInfo:nilrepeats:YES];下面是检测RSSI的代码-(void)detectRSSI{[self.peripheralreadRSSI];}那么问题是,该函数工作正常,但是当我将时间间隔设置为小于1.2秒时,peri

ios - <错误> : [CoreBluetooth] API MISUSE: Cancelling connection for unused peripheral

我的场景:我用sigkill()终止了我的应用程序->应用程序进入后台。数据从BT设备发送,并在调用centralManager:willRestoreState:时成功连接。连接设备后,我将BT设备移出应用程序范围,方法centralManager:didDisconnectPeripheral:error:被调用,错误代码为6。我尝试通过调用[_centralManagerconnectPeripheral:peripheraloptions:nil]重新连接外围设备,然后出现以下错误:[CoreBluetooth]APIMISUSE:Cancellingconnectionfor

objective-c - 具有回调方法的 IOS Grand Central Dispatch

我没有在我的应用程序中使用GCD或太多线程,但我遇到过需要在另一个线程上运行一两个方法的情况。此方法完成后,我需要使用回调中的主线程调用另一个方法。我一直在四处寻找如何检测线程何时完成操作但仍然不太清楚这个问题。我创建了一个测试应用程序,并使用了viewDidLoad方法作为一个快速示例。-(void)viewDidLoad{[superviewDidLoad];//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.dispatch_async(dispatch_get_global_queue(DISPATCH_QUE

ios - 如何将 dispatch_data_t 转换为 NSData?

这是正确的方法吗?//convertconstvoid*buffer=NULL;size_tsize=0;dispatch_data_tnew_data_file=dispatch_data_create_map(data,&buffer,&size);if(new_data_file){/*toavoidwarningreally-sincedispatch_data_create_mapdemandswecareaboutthereturnarg*/}NSData*nsdata=[[NSDataalloc]initWithBytes:bufferlength:size];//use

tcp - 如何使用 openresty lua 中的第一个字节内容将 tcp 请求分派(dispatch)到后端

我已经启动了一个带有一个tcp服务器和两个后端的openresty。tcp服务器根据来自tcp流的内容将请求分派(dispatch)给后端。以下是openresty配置示例:stream{#defineaTCPserverlisteningontheport1234:upstreambackend1{server172.17.0.1:8081;}upstreambackend2{server172.17.0.1:8082;}server{listen1234;content_by_lua_block{localsock=ngx.req.socket(true)--reveivefirs

swift - 使用 dispatch_after swift 延迟 'glitch'

目前我有一个延时函数如下://Delayfunctionfromhttp://stackoverflow.com/questions/24034544/dispatch-after-gcd-in-swift/24318861#24318861funcdelay(delay:Double,closure:()->()){dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(delay*Double(NSEC_PER_SEC))),dispatch_get_main_queue(),closure)}此代码可满足我的需要,但一旦延迟超过1