Q 4 Gurus and Internists (Structured Storage)

Q 4 Gurus and Internists (Structured Storage)

Post by Jerem » Fri, 15 Jun 2001 00:54:44



Gurus and Internals Specialists:

Say, I'm opening a compound doc file and create a bunch of streams in
it, and give those streams to a bunch of threads, one per thread. Then I
start writing to those streams from those different threads.

The question is: will there be any implicit synchronization or other
impact on interthread timing (other than that related to the writing
itself, like the size of writes, etc.)? Iow, will that change the
timing?

Or, differently: I could give every thread a heap so that this thread
could write to it, then all threads would be completely independent of
one another. Is using a compound file the same in that respect, or there
will be some hidden influence?

 
 
 

Q 4 Gurus and Internists (Structured Storage)

Post by Igor Tandetni » Fri, 15 Jun 2001 02:46:03


I've found just one article that talks about compound documents and threads:

http://msdn.microsoft.com/library/psdk/com/com_1fuh.htm

I quote:

OLE compound document applications call the OleInitialize function, which
calls CoInitializeEx and also does some initialization required for compound
documents. Therefore, threads that call OleInitialize cannot be
free-threaded. For information on threading in clients and servers, refer to
Processes, Apartments, and Threads.

If this is true, every thread that uses compound documents must use
OleInitialize, must therefore be in STA, so you must marshal all them
IStream pointers from the thread that creates the storage to the worker
threads, which means all calls on those IStreams get marshaled right back to
the original thread, and all the actual I/O is done by one thread. I doubt
that's what you had in mind.
--
With best wishes,
    Igor Tandetnik


Quote:> Gurus and Internals Specialists:

> Say, I'm opening a compound doc file and create a bunch of streams in
> it, and give those streams to a bunch of threads, one per thread. Then I
> start writing to those streams from those different threads.

> The question is: will there be any implicit synchronization or other
> impact on interthread timing (other than that related to the writing
> itself, like the size of writes, etc.)? Iow, will that change the
> timing?

> Or, differently: I could give every thread a heap so that this thread
> could write to it, then all threads would be completely independent of
> one another. Is using a compound file the same in that respect, or there
> will be some hidden influence?


 
 
 

Q 4 Gurus and Internists (Structured Storage)

Post by Jerem » Fri, 15 Jun 2001 03:36:02



> I've found just one article that talks about compound documents and threads:
> http://msdn.microsoft.com/library/psdk/com/com_1fuh.htm

> I quote:

> OLE compound document applications call the OleInitialize function, which
> calls CoInitializeEx and also does some initialization required for compound
> documents. Therefore, threads that call OleInitialize cannot be
> free-threaded.

I seem to remember that (in the past, it's not fresh in my mind) I've
use a structured file in an MT environment. The trouble is, at the time
I didn't care for any timing, and moreover, the whole thing was
distributed, so even the environment was not exactly like what I need.)
I hope I remember it right, but we'll see what your document says.

For information on threading in clients and servers, refer to

Quote:> Processes, Apartments, and Threads.

> If this is true, every thread that uses compound documents must use
> OleInitialize, must therefore be in STA, so you must marshal all them
> IStream pointers from the thread that creates the storage to the worker
> threads, which means all calls on those IStreams get marshaled right back to
> the original thread, and all the actual I/O is done by one thread. I doubt
> that's what you had in mind.

Damn right <g>. If that's how it works, I'm toast with this idea. I'll
go check the link you've posted.

Thanks.

Quote:> --
> With best wishes,
>     Igor Tandetnik

 
 
 

Q 4 Gurus and Internists (Structured Storage)

Post by Jerem » Fri, 15 Jun 2001 03:53:10


Nah, just looked at the old snippet:
there I called StgCreateDocfile(...) in an MT-initialized executable and
then handed out streams to remote clients on request. Worked fine. Btw,
I didn't call any OleInitialize, just CoInitializeEx (...multi-threaded
)

There's hope it's not as bad as this msdn section seems to suggest <g>.

 
 
 

Q 4 Gurus and Internists (Structured Storage)

Post by Igor Tandetni » Fri, 15 Jun 2001 04:02:27


I won't be overly surprised if StgCreateDocfile creates an
apartment-threaded COM object, in which case COM spins an STA thread to
service it and marshals its interface pointer to your MTA thread, and actual
I/O is still confined to one thread. Can't find it documented anywhere,
though.
--
With best wishes,
    Igor Tandetnik


Quote:> Nah, just looked at the old snippet:
> there I called StgCreateDocfile(...) in an MT-initialized executable and
> then handed out streams to remote clients on request. Worked fine. Btw,
> I didn't call any OleInitialize, just CoInitializeEx (...multi-threaded
> )

> There's hope it's not as bad as this msdn section seems to suggest <g>.

 
 
 

Q 4 Gurus and Internists (Structured Storage)

Post by Jerem » Fri, 15 Jun 2001 06:53:34



> I won't be overly surprised if StgCreateDocfile creates an
> apartment-threaded COM object, in which case COM spins an STA thread to
> service it and marshals its interface pointer to your MTA thread,

A good point, I'll keep this thing in mind.

and actual

Quote:> I/O is still confined to one thread. Can't find it documented anywhere,
> though.
> --
> With best wishes,
>     Igor Tandetnik

 
 
 

1. IStream / Structured Storage

I'm not sure if I should ask this question here but here goes:

I have created a structured storage document and created a stream.

What is the fastest way ( straight C - non CPP - non MFC ) to read and
store a disk based file (22mb big) into that stream?  (this is on Win 98).

Thanks in advance.

Sylvio

2. Need basic tutorial about MSFT programming resources

3. How to reclaim space in Structured Storage

4. 2000 Server in NT 4 Domain Model

5. A whole file in Structured Storage?

6. FS: XE, STE, Falcon030 + Lots 'o' Stuff

7. OLE Structured storage...summary information

8. Best price for HP 722

9. OLE 1 and Structured Storage question

10. Newbie VC6 and Structured Storage Question

11. Is CoInitialize necessary to use structured storage?

12. Structures Storage question