Reply to comment

strict warning: Only variables should be passed by reference in /var/www/www.waterworld.com.hk/sites/all/modules/captcha/captcha.inc on line 61.

Set priority in custom queue of GCD

In iOS GCD, you can use GCD queue to serialize operation by using DISPATCH_QUEUE_SERIAL parameters:

queue = dispatch_queue_create("hk.com.waterworld.previewRenderQueue", DISPATCH_QUEUE_SERIAL);

then you can create a queue dispatch like:

dispatch_async(self.renderQueue, ^{
... your code here ...
});

but the priority of the queue is unknown, so sometimes, when you queue a lot of task to this queue. It still block the foreground task and make the user interface not smooth.

If fix it, we can:

dispatch_async(self.renderQueue, ^{
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
... your code here ...
});
});

that using combination of dispatch_sync and dispatch_get_global_queue to route this block to another priority queue. To use dispatch_sync before we want to keep the serialisation property of our queue.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
7 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.