Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 12
Registered: ‎09-18-2013
My Device: Z10
My Carrier: none

Grand Central Dispatch

Anybody having experience with using Grand Central Dispatch with Blackberry?

 

Found this:

http://opensource.mlba-team.de/xdispatch/docs/current/group__qtdispatch.html

 

Any experiences with it?

 

I'm porting an iOS App to Blackberry 10 which uses GCD for handling Threads. Would be nice to have sth similar in BB 10.

Contributor
Posts: 12
Registered: ‎09-18-2013
My Device: Z10
My Carrier: none

Re: Grand Central Dispatch

[ Edited ]

to get a little more into detail what i want to do:

 

in my ios app i use this to get a background thread and to make calls into the main thread:

 

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
         // do stuff in background
         dispatch_async(dispatch_get_main_queue(),^{
           // do stuff in main thread
         });
});
any idead in how i can implement this in bb 10? already looked at qthread and stuff, but seems like a lot of overhead, since it's so simple in gcd Smiley Wink
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Grand Central Dispatch

I don't know anything about Grand Central (I only do Android and BlackBerry apps) Smiley Happy

 

However if you just want a minimal overhead asynchronous call there are many alternatives the simplest probably being a QtConcurrent call this and others talked about here,

 

http://developer.blackberry.com/native/reference/cascades/threads.html

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 12
Registered: ‎09-18-2013
My Device: Z10
My Carrier: none

Re: Grand Central Dispatch

Already saw this, but is it also possible to force execution in main thread, when working in background?

 

 

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Grand Central Dispatch

What do you mean by force execution? Both the main and the background thread will be being processed.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 12
Registered: ‎09-18-2013
My Device: Z10
My Carrier: none

Re: Grand Central Dispatch

of course, but I have some stuff that needs to be executed in the main thread, so I would have to access the main thread from the background thread (like in my little gcd sample above)

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Grand Central Dispatch

Yes you can use QT's signal/slot mechanism to communicate between the two.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 12
Registered: ‎09-18-2013
My Device: Z10
My Carrier: none

Re: Grand Central Dispatch

yes, but this doesn't seem to work with the QtConcurrent stuff

 

guess i would have to do the stuff with worker classes and signal/slots

 

 

this really sucks, i want gcd!!! Smiley Very Happy with gcd it is so simple

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Grand Central Dispatch

This is the reason I use AsyncWorker, QThread and QtConcurrent in my app, they all have their targetted uses.

 

QtConcurrent's being mainly to fire off a quick single function call and get a result.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Grand Central Dispatch

If gcd is opensource you can always port it.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.