[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CriticalSection in VisaulC++ in C



All
#define VisaulC VisualC

Thanks for the replies. What confused me originally was really 
why C was so prevalent in C++ Win32, and how I should think in
those cases.
C/C++ Users Journal May 2000 has some articles on multithreading.
www.cuj.com/code May2000 howard.zip, calkins.zip.

Calkins states:

  Here Run is implemented by class Thread, though it could also be
made virtual and implemented by subclasses of Thread if only one 
thread in the object is desired.
  If the object requires multiple threads, it may be more convenient
to directly implement multiple Run-style member functions as needed,
rather than use Thread as an abstract base class.
  It is important to note that the thread function must be a C-style 
function, not a member function.
Charles Calkins, "Integrating Threads with Template Classes", 
C/C++ Users Journal, May 2000 page 32.

Comment: 
Q1. Does this tell me that _multi_threading and inheritance the 
    OO way are "incompatible"? In many cases I'd want different 
    Run-methods, but why would I want that in the same object, 
    if the Run-methods were different? Maybe to implement different
    flavours of a filter process? But why couldn' these flavours 
    have one Thread class each, the Run methods would differ anyhow?
    And they would differ more than inhertiance and polymorhism offer. 
    What exactly does OO offer in this case?
Q2. Why does it have to be a "C-style function". Is Win32 a non-OO
    system?

Another article, Using predicate waits with Win32 threads - Howard, C/C++
Users Journal, May 2000 even mentions Hoare etc. and goes on to design
some interesting code. He states that:

Java        Windows
wait      = SignalObjectAndWait (Win-98 and Win-2000)
notify    = PulseEvent with autoreset
notifyAll = PulseEvent with manual reset

Is this correct?

-- 
Oyvind
(------------------------------------------------------------------(
)       Oyvind Teig )          oyvind.teig@xxxxxxxxxxxx ) Tel: +47 )
( Navia Maritime AS (          oyvind.teig@xxxxxxxxxxxx ( 73581268 (
)    div. Autronica )                                   ) Fax: +47 )
(    7005 Trondheim (           http://www.autronica.no ( 73581001 (
)            Norway )                                   )          )
(------------------------------------------------------------------(
)                    http://www.autronica.no/pub/tech/rd/index.htm )
(------------------------------------------------------------------(