views:

49

answers:

1

I have a COM EXE out-of-proc server exposing an API from one of its interfaces. The functionality of this API is to post URLs.

My client will be creating the instance of the COM server and calling this API with new URLs.

Every time client needs to post a URL it will create an instance of this COM server.

Do I need to implement a queue in the COM server to keep track of all URLs posted by client and making sure nothing is lost?

What I am wondering is if every time I create a COM object, a new process will be launched? If that's the case, I think I don't need to implement job queue in server.

But if only one instance remains in memory, is it possible that the jobs/URLs posted by client can be lost.

+1  A: 

COM usually starts one server process for all requests and instantiates all objects in that process. If you have any data shared between all objects (global variables or static member variables) you should either take care of synchronization or make the COM component apartment-threaded (STA).

If you don't have synchronization and the component is multi-threaded (MTA) all the data shared between instances is subject to corruption if it is written by more that one thread at a time.

sharptooth
Okay, my COM server is single threaded . So can I put multiple requests to COM server ? I also want COM server to take request and return immediately.It looks like I have to implement a second thread in COM server which takes care of posting URLS .
Alien01
If the component is STA you can post multiple requests, but if a request is executed all the subsequent requests will be silently suspended until that first request returns and after that one of the pending requests is resumed. This is done automatically by COM to prevent shared variables corruption. You can spawn whatever amount of threads you need inside, but then you'll have to take care of synchronization.
sharptooth