views:

383

answers:

6

I have an API call in my application where I am checking the time taken for a single call. I have put this in a FOR loop and using 10000 calls to get the average times of all calls. Now the issue which came up was that the actual application using the API, is multi-threaded. If I wish to make my application also do the same, how would I go about doing this?

The platform is REL and my aim is to send multiple calls in the same time with either the same parameters or different parameters. Can this be implemented in C++ and if so, what library functions to use and can an example be provided for the same?

+6  A: 

Probably the best C++ library to use for threading is the thread library in Boost, but like all C++ threading, you will be forced to manually do your synchronization. You will need to use mutex and lock types to make it work properly. Your question isn't very clear, so I can't really help you any more (though I think you don't actually need threading, but I could be completely misunderstanding).

coppro
thanks, will try out the boost library.
gagneet
A: 

In what platform? Just about every one supports threads, and I imagine they all have documentation on how to create a thread. Under Windows you'd call the CreateThread API.

ctacke
i am using REL. Was unable to fin one which would suitably run for my application.
gagneet
A: 

Pthreads is how you'd do it with Linux. Solaris Threads for Solaris.

Paul Nathan
thanks will try out with pthreads.
gagneet
+1  A: 

If you read the Miranda IM source code, it should get you started. It's very well done and there are some nice hints in the code for how to rebase the memory offsets of other executables (on Windows) to make them load faster.

http://www.miranda-im.org/development/

Chrelad
A: 

I'm not familiar with the REL platform. In general, I prefer Intel's TBB for threading, but it only runs on x86 chips right now.

Max Lybbert
+1  A: 

I don't know the REL platform.

I may suggest the OMP alternative, it's not exactly Threads per say, but it does the job and it's quite easy to use for this kind of scenario. Apparently it run on quite some compilers.

call me Steve