大佬教程收集整理的这篇文章主要介绍了iOS:核心图像和多线程应用程序,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是什么意思?
我实际上是试图在后台线程上运行我的过滤器,@R_291_9447@在主线程上运行HUD(见下文).这在core@L_618_1@的上下文中是否有意义?我认为核心图像固有地使用GCD.
//start HUD code here,on main thread // Get a concurrent queue form the system dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); dispatch_async(concurrentQueue,^{ //Effect image using Core Image filter chain on a BACkground thread dispatch_async(dispatch_get_main_queue(),^{ //dismiss HUD and add fitered image to imageView in main thread }); });
更多来自Apple Docs:
//start HUD code here,on main thread // Assuming you already have a CIFilter* variable,created on the main thread,called `myFilter` CIFilter* filterForThread = [myFilter copy]; // Get a concurrent queue form the system dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,^{ CIFilter filter = filterForThread; // Effect image using Core Image filter chain on a BACkground thread dispatch_async(dispatch_get_main_queue(),^{ //dismiss HUD and add fitered image to imageView in main thread }); }); [filterForThread release];
这里发生的是filterForThread是myFilter的副本.在传递给dispatch_async的块中引用filterForThread将导致该块保留filterForThread,然后调用范围释放filterForThread,这有效地完成了filterForThread对块的概念所有权的转移(因为块是唯一留下引用的块)它). filterForThread可以被认为是执行块的线程的私有.
这应该足以满足此处的线程安全要求.
以上是大佬教程为你收集整理的iOS:核心图像和多线程应用程序全部内容,希望文章能够帮你解决iOS:核心图像和多线程应用程序所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。