Threading in MT

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Threading in MT

Nic Wise
Hi there

I'm curious what MT uses for threadpools under the hood. Does it use
whatever Apple's ones are (NSOperation?) or something like pthreads?
(the same way WebClient et al use sockets, vrs NSUrl and the like,
which the OS has hooks in to keep the WWAN open....)

Thanks, assuming any of that makes sense :)

Cheers

N

--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/ | http://www.flickr.com/photos/nicwise
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Miguel de Icaza
Hello,

> I'm curious what MT uses for threadpools under the hood. Does it use
> whatever Apple's ones are (NSOperation?) or something like pthreads?
> (the same way WebClient et al use sockets, vrs NSUrl and the like,
> which the OS has hooks in to keep the WWAN open....)

When you use threads from the ThreadPool, those use native Mach kernel
threads.

When you use asynchronous operations and asynchronous method
invocations (those that have .Async in their name) they are queued
through the threadpool.

Up until MonoTouch 3.xx we were using the .NET-style ThreadPool,
starting with MonoTouch 4.x, we use a new, more scalable, threadpool
system.

NSOperation is merely an encapsulation for a task that you can schedule to run.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Nic Wise
Thanks - so there is no major difference, if, say, one had a
multi-core iOS device :) , in using ThreadPool vrs NSOperation (or
whatever the Cocoa(Touch) class is which does threading)?

And in the tradition of killing kittehs... if I'm not using IB, is
monotouch 4 alpha (beta?) stable enough for day to day use and
submission to the appstore?

I'm just about to release a version of one of my apps (using 3.x), but
after that, I'd love to use the bleeding edge stuff, assuming I can
roll back to 3.x if it all goes to custard.....

On Thu, Mar 17, 2011 at 15:34, Miguel de Icaza <[hidden email]> wrote:

> Hello,
>
>> I'm curious what MT uses for threadpools under the hood. Does it use
>> whatever Apple's ones are (NSOperation?) or something like pthreads?
>> (the same way WebClient et al use sockets, vrs NSUrl and the like,
>> which the OS has hooks in to keep the WWAN open....)
>
> When you use threads from the ThreadPool, those use native Mach kernel
> threads.
>
> When you use asynchronous operations and asynchronous method
> invocations (those that have .Async in their name) they are queued
> through the threadpool.
>
> Up until MonoTouch 3.xx we were using the .NET-style ThreadPool,
> starting with MonoTouch 4.x, we use a new, more scalable, threadpool
> system.
>
> NSOperation is merely an encapsulation for a task that you can schedule to run.
>



--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/ | http://www.flickr.com/photos/nicwise
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Miguel de Icaza
Hello,

> Thanks - so there is no major difference, if, say, one had a
> multi-core iOS device :) , in using ThreadPool vrs NSOperation (or
> whatever the Cocoa(Touch) class is which does threading)?

Well, NSOperation merely encapsulates the activity.   You still have
to schedule it, how you schedule that one has a few parameters, so you
might want to check on what NSOperation offers.   I believe some of
the schedulers allow you to execute operations in order, like a queue,
using a single thread.

With MonoTouch 4, you also have a new construct called a Task (from
System.Threading), part of the parallel framework.   And you also have
a choice of how you schedule this task for execution.   The default
scheduler merely uses the Mono threadpool.   Other schedulers provide
different options, or you can write your own.

> And in the tradition of killing kittehs... if I'm not using IB, is
> monotouch 4 alpha (beta?) stable enough for day to day use and
> submission to the appstore?

I use it for TweetStation 2.   We certainly could use people's
feedback on this.

In general, it should generate better code with LLVM, but you really
need to test your app, and let us know if we missed something, or if
there is a regression.

> I'm just about to release a version of one of my apps (using 3.x), but
> after that, I'd love to use the bleeding edge stuff, assuming I can
> roll back to 3.x if it all goes to custard.....

You can roll back.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Nic Wise
> Well, NSOperation merely encapsulates the activity.   You still have
> to schedule it, how you schedule that one has a few parameters, so you
> might want to check on what NSOperation offers.   I believe some of
> the schedulers allow you to execute operations in order, like a queue,
> using a single thread.

OK. By the sounds of it, I'm good sticking with either
ThreadPool.QueueUserWorkItem or the new Task stuff :)


sweeeet :)

> I use it for TweetStation 2.   We certainly could use people's
> feedback on this.
>
> In general, it should generate better code with LLVM, but you really
> need to test your app, and let us know if we missed something, or if
> there is a regression.

OK, once I have this release out tonight, I'll fire up xcode 4 and see
how it all goes!

> You can roll back.

Lovely. That's enough for me to try it. Thanks Miguel!


N
--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/ | http://www.flickr.com/photos/nicwise
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Miguel de Icaza

> OK. By the sounds of it, I'm good sticking with either
> ThreadPool.QueueUserWorkItem or the new Task stuff :)

Right, the new Task stuff just happens to have many prettier use cases
than manually calling QueueUserWorkItem, and it integrates with things
like Parallel.For and so on.

> OK, once I have this release out tonight, I'll fire up xcode 4 and see
> how it all goes!

Oh, I meant to say *MonoTouch 4*, not XCode 4.   We do not have support
for the new IDE features in XCode 4, and we strongly advise you to not
move until we ship the code to support it.

>
> > You can roll back.
>
> Lovely. That's enough for me to try it. Thanks Miguel!
>
>
> N


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Nic Wise
> Oh, I meant to say *MonoTouch 4*, not XCode 4.   We do not have support
> for the new IDE features in XCode 4, and we strongly advise you to not
> move until we ship the code to support it.
>

OOOOOOOOOOOOOH. OK. So I can use MT4 with the xcode 3.x?

That makes it a lot easier. Sorry, I thought MT4 worked _only_ xcode 4.

(did I miss something, or is the webpage not clear about it?)

--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/ | http://www.flickr.com/photos/nicwise
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Miguel de Icaza

> OOOOOOOOOOOOOH. OK. So I can use MT4 with the xcode 3.x?

yes.

> That makes it a lot easier. Sorry, I thought MT4 worked _only_ xcode 4.
>
> (did I miss something, or is the webpage not clear about it?)

We have an announcement, let me know if it is unclear.


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Threading in MT

Nic Wise
> We have an announcement, let me know if it is unclear.
>

Reading back on the website, it's not unclear, tho I did make some
assumptions - MT4.0 being for xcode 4.0 etc.

Glad it's not :)


--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/ | http://www.flickr.com/photos/nicwise
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch