Sign in to follow this  
JamesCobras

Portable Multithreading

Recommended Posts

Hi guys. I'm creating an app and i want to run winsock functions in one thread and the rest of the app in an other. I'm considering multithreading to allow processing and networking to occur at the same time. I would really like to do this portably. I wouldn't mind on the server as i can chose, but on the client i would really like multithreading. How can i multithread portably. I might want to port to linux, mac and iphone (just to give an example). Are there any Standard (platform/OS independent) ways of multithreading. Cheers JamesCobras

Share this post


Link to post
Share on other sites
Quote:
Original post by JamesCobras

I'm creating an app and i want to run winsock functions in one thread and the rest of the app in an other.


Winsock == Windows Sockets. Not portable in the first place.

Quote:
I'm considering multithreading to allow processing and networking to occur at the same time.

Are you aware of non-blocking sockets, as they are defined by Berkeley Sockets API (of which Winsock is an implementation) and is available in all *nix systems.

This is probably the least important reason to use multi-threading.

Quote:
I wouldn't mind on the server as i can chose, but on the client i would really like multithreading.
Why?

Quote:
How can i multithread portably.
You can't.

Quote:
I might want to port to linux, mac and iphone (just to give an example).
I was under impression iPhone isn't multi-threaded by design.

Macs also offer GCD, which is likely a much better solution for concurrency.

Quote:
Are there any Standard (platform/OS independent) ways of multithreading.
Yes, for some subset of OSes. Windows/Linux has pthreads. Otherwise, threading is provided by either OS or the language platform (.Net/Mono, Java and similar).

All threading libraries are just wrappers on top of those, with specific version for each platform. Threading is something that is completely tied into OS kernel, perhaps even hardware.


What is your business case? Why do you need to support everything from Windows over Linux down to iPhone. This is broader than most large companies can afford to cover.

Share this post


Link to post
Share on other sites
cheers for the response.

You actually just solved my problem, i'm being unrealistic.

I wanted, in essence a suped up chat program that'll run on anything.

Alas, i feel that this is not possible in one fell sweep.

To add portability i will probably be using ifdef's till the cows come home.

Can't believe i thought winsock (2) was portable.... fail!

Well that solved my problem straight away.

JamesCobras

Share this post


Link to post
Share on other sites
Quote:
Original post by JamesCobras

I wanted, in essence a suped up chat program that'll run on anything.


How about HTML/AJAX web app? It will run on anything, including iPhone, android, ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this