Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* c++ & pthreads: oil and water ?
@ 1997-11-12  5:00 magrasjc
  1997-11-12  5:00 ` Douglas C. Schmidt
  1997-11-18  5:00 ` Jochen Klein
  0 siblings, 2 replies; 4+ messages in thread
From: magrasjc @ 1997-11-12  5:00 UTC (permalink / raw)
  To: rwhite, kris


Note:There is a crosspost to news:comp.lang.c++.moderated

Greetings,

How does a program integrate Posix threads and C++? It would be a major
impasse for one to
preclude the use of the other.... but C++ is allergic to void * which
pthread_create() uses
for 2 arguments.

rwhite@pobox.com wrote:
(It doesn't seem to work in DEC UNIX 3.2 /g++ 2.7.2.2 ....
pthread_create call:  conversion from `void *' to non-scalar type
`CMA_T_HANDLE' requested
first line of ThreadEntry::Invoke's definition header : parse error
before `::'
typedef void * (*start_func)(void *);

template <class T> class ThreadEntry    {
    T *                                   Object;
    void *                             (T::* Member)(void);
     static void *                    Invoke(ThreadEntry<T> *);
public:
                                            ThreadEntry(T * Target, void

*(T::* func)(void)):
                                                Object(Target),
Member(func)    {
                                                pthread_t    threadID;

pthread_create(&threadID,NULL,Invoke,(void *)this);

RegisterThread(threadID);
                                            };
};

template <class T> void * ThreadEntry::Invoke(ThreadEntry<T> * Target)
{
    void * retval = Target->(Object->*Member)();
    delete Target;
    return retval;
}

NOTE: I call a function called "RegisterThread".  This is *not* found in

any
library ... you must define it.

--
 Unix Software Engineer looking for C++/UNIX/Motif/Perl/Tk/Flex
 Software Engineering position **NOW**. Currently in Austin at
 (512) 672-5778/magrasjc@texas.net. have Answering machine.






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-11-18  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-11-12  5:00 c++ & pthreads: oil and water ? magrasjc
1997-11-12  5:00 ` Douglas C. Schmidt
1997-11-18  5:00   ` Dalibor Carapic
1997-11-18  5:00 ` Jochen Klein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox