cocoa - How can I make sure NSOperations execute in a failsafe way? -
what do i want
I have received an NSOperationQueue in my application and It is important that all actions will be processed before the end of the application. Before leaving I was left to make sure the NSOperationQueue is empty:
if ([NSThread isMainThread]) {while ([[Operation Quyu Operations]] gt; 0] { [[NSRunLoop Current RunLoop] runUntilDate: [NSDT date date time interval now: 0.05]]; }} And {{Operation Quiz Wait UNN OperationErefined]; }
I have had a problem with my code, where before it ends an NSOperation "fridge" and it blocks the whole line, obviously, like this Under the circumstances, my code should throw an exception, which now does.
But I still want to protect against any strange incident, where the operation stops and blocks the queue, resulting in the application never gets.
My Crap Solution
I am contemplating an end to a line ending my operation. Then when this time expires, I can throw an exception, then the problem can be caught.
However, this does not seem right. Ideally, I should not have to depend on the timer to ensure that the work has been done.
My question
Is there a better, unsuccessful safe, way to ensure that my operation is not frozen?
If I think ...
- You want to know That your operation is not frozen .. it goes ...
- Would you like to know that all your tasks will end ... ... gets ...
- You Want to solve
Good luck with that.
However, whatever you are doing with waitUntilAllationsAreFinished
, as you are about to achieve, you can add a second class which will be assigned to each operation And ensures that it does not last long enough (you call it more than 10x taller than it is expected to run), at that point it will be -cancel
code> NSOperation ( More or less your timer approach). However, even this is not easy, because the operation can be blocked on something where you can not check for - equivalent
(for example, inside the system call).
Comments
Post a Comment