Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: magrasjc@texas.net
To: rwhite@pobox.com, kris@snet.net
Subject: c++ & pthreads: oil and water ?
Date: 1997/11/12	[thread overview]
Message-ID: <3469D2DB.58D695B9@texas.net> (raw)


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.






             reply	other threads:[~1997-11-12  5:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-12  5:00 magrasjc [this message]
1997-11-12  5:00 ` c++ & pthreads: oil and water ? Douglas C. Schmidt
1997-11-18  5:00   ` Dalibor Carapic
1997-11-18  5:00 ` Jochen Klein
read-only archive

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