问题标签 [nsoperationqueue]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
351 浏览

cocoa - 即使我使用 nsoperations 并将 maxConcurrentOperationCount 设置为 3,我的 mac os x 应用程序也没有响应

我一直在研究堆栈溢出,但从来没有真正有机会提出我的第一个问题,所以这里是:

我正在开发一个 mac os x 应用程序并使用 nsoperations 来保持应用程序响应,我还将 maxConcurrentOperationCount 设置为 3,但是该应用程序在工作时仍然有些无响应,如果它试图移动窗口我可以看到它开始滞后和行为不规律

有人可以提供任何线索或解决方案的指针吗?(不,不询问示例代码;)

0 投票
1 回答
263 浏览

iphone - 如何从崩溃日志中识别错误

我的应用程序在我构建和调试时运行良好,但当我自己运行时,它由于其他一些问题而崩溃。
我有一个 NSObject 类、一个 UITableView 类、一个 UIView 类、一个 UITableViewCell 类和一个 NSOperation 类。是否有任何机构有类似的问题,或者是否有人可以帮助我。

0 投票
1 回答
549 浏览

iphone - 需要使用 NSOperationQueue 来解析两个不同的 NSOperation 类

试图解析两个具有 XML 数据的不同 URL。

我有两个不同的 NSOperation 类,它们都独立工作,因为它们都有自己的工作要完成。我有一个 parseQueue,它是 NSOperationqueue,我在其中添加了两个不同的操作。

基本上我试图分别解析两个 xml 数据并希望有并发操作。但是当第二个操作完成加入队列时,它仍然会查看第一个类操作。我迷失了,因为我不知道为什么即使在发布后它仍在寻找头等舱。任何人都可以提出一些想法并帮助我。

0 投票
1 回答
1412 浏览

ios - iOS 上的 OpenGL。可以在单独的线程上调用 glTexImage2D 吗?

在 iOS 上,我一直认为不可能通过 NSOperation 子类在单独的线程上创建 OpenGL 纹理 - glTexImage2D。有人可以确认/拒绝。

由于纹理创建可能会挂起 GUI - 糟糕!- 有没有人想出一个他们满意的解决方法?

谢谢,
道格

0 投票
3 回答
4506 浏览

multithreading - NSOperationQueue,NSOperation

我是 iPhone 新手。NSOperationQueue我在哪里得到例子NSOperation?,相对于线程有什么
优势?NSOperationQueueNSOperation

谢谢

0 投票
2 回答
11918 浏览

iphone - iOS - 如何检查 NSOperation 是否在 NSOperationQueue 中?

从文档:

一个操作对象一次最多只能在一个操作队列中,如果该操作已经在另一个队列中,则此方法会抛出 NSInvalidArgumentException 异常。同样,如果操作当前正在执行或已经完成执行,则此方法会引发 NSInvalidArgumentException 异常。

那么如何检查是否可以安全地将 NSOperation 添加到队列中?

我知道的唯一方法是添加操作,然后如果操作已经在队列中或之前执行,则尝试捕获异常。

0 投票
1 回答
2246 浏览

iphone - addOperation (OSAtomicCompareAndSwap32) 上的应用程序崩溃

任何人都知道为什么应用程序在这个地方崩溃在代码中我正在做这样的事情

错误代码

0 投票
1 回答
610 浏览

cocoa - Debugging NSOperationQueue Blocking

I need some guidance in how to debug problems with concurrency in Cocoa under 10.6. I'm converting a 'for' loop to use NSOperations but most of the time, the code just freezes at some point through the loop. I can see NSLog output in the console to that effect. On the rare occasion, the code will run all the way through and it's fine.

The code is model-layer only, initiated from a method in the controller. The method loops through just 8-10 model objects, instructing them to each write their output to a uniquely named file. 8 model objects = 8 separate files. There are no calls up to the GUI and the model objects are NSManagedObject subclasses, which contain a set of child NSManagedObject objects (0..n of them), which each owning object summarizes and writes out. The output format is JSON.

Code:

I do a lot of NSLogs, would that be the issue? Is NSLog'ing from background threads a bad thing?

Since I'm adding to the mutable array from withinside a block, is it correct that I declare the mutable array as __block? I've tried it both ways and seemingly no difference relating to this freezing problem.

How do I debug this problem using Xcode v4? I want to know the line of code that it's freezing on, or what two lines of code are executing at the same time and causing it to block the execution.. My former techniques of setting a single breakpoint and stepping through the code no longer work, because of the concurrency.

thanks

0 投票
2 回答
1484 浏览

iphone - NSOperationQueue 和 UITableView

我正在从 SQLite 数据库加载一些数据以显示在UITableView. 为了确保用户没有被阻塞并且表格可以快速显示,我正在创建一个队列并添加要在后台执行的数据库操作。

添加很好并且工作正常,但由于某种原因随机一些行没有用数据更新!

我知道数据设置正确,因为当我单击该行时,该行将使用我的数据进行更新,但我似乎找不到更新 UI 的方法!我已经尝试了一切,包括使用setNeedDisplay等等,但没有任何效果!

这是我的代码:

0 投票
0 回答
813 浏览

cocoa - 让基于运行循环的 NSThread 休眠一段不确定的时间

我的 iOS 应用程序中有一个专用的网络线程。线程的 -main 方法如下所示:

我有一个 NSOperationQueue 填充了 http 操作(并发,基于运行循环的 NSOperation 子类)。现在,因为我知道什么时候有 http 操作需要 runloop 线程,所以我希望能够防止 runloop 线程在没有工作要做的时候执行。我在某处读到(有帮助,我知道)NSRunLoop 在没有工作时会自动休眠。但是,我使用 Instruments 的时间分析器并看到 runloop 线程始终处于活动状态。

如何安排我对 NSRunLoop 和 NSThread 的使用以防止这种资源浪费?