Re: Is it safe to send one thread's stack buffer pointer to another th
Actually, there's further optimization possible since the marshal
request indicates the target context as in-proc, thus more efficient
marshaling is possible for certain types. This typically involves
custom marshaling though. An example is the Free-Threaded
Marshaler that does no marshaling whatsoever and causes direct
interface pointer access from all apartments in the process (it
only involves marshaling interface pointers).
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:upkg%23Y14HHA.5724@TK2MSFTNGP05.phx.gbl...
Ben Voigt [C++ MVP] <rbv@nospam.nospam> wrote:
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:ugZ20n04HHA.4476@TK2MSFTNGP06.phx.gbl...
Ben Voigt [C++ MVP] <rbv@nospam.nospam> wrote:
COM marshalling would be a good reason to do so.
COM marshalling doesn't just pass a pointer to the stack frame over
to the other thread. It actually serializes all the parameters into
a binary stream and sends that over. On the other end, the stream is
deserialized and a copy of the stack frame is recreated.
I know that's true for inter-process DCOM, but does DCOM marshalling
of an in-process component do the same?
It has to. Some parameters may have to change in the process. E.g. COM
interface pointers might need to be replaced with pointers to proxies -
and thus any structures containing interface pointers, including but not
limited to SAFEARRAYs and VARIANTs, need to be copied and populated with
modified values.
So the exact same code is used to serialize and deserialize marshalling
packet. The only optimization between in-proc and out-of-proc case is how
the marshalling packet is transferred to destination: in the in-proc case,
it's just allocated in memory and the pointer is passed to target thread,
while in the out-of-proc case it's transferred across process boundaries
by some IPC mechanism (called LRPC for "lightweight remote procedure
call", which I believe ultimately uses memory-mapped files to move data
around).
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925