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

* Re: c++ & pthreads: oil and water ?
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Douglas C. Schmidt @ 1997-11-12  5:00 UTC (permalink / raw)



In article <3469D2DB.58D695B9@texas.net>,  <magrasjc@texas.net> wrote:
++ 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.

This is a FAQ.  I recommend that you check out

http://www.cs.wustl.edu/~schmidt/ACE-concurrency.ps.gz

for information on how we do this in ACE.  You can get the C++ source
code for this solution at

http://www.cs.wustl.edu/~schmidt/ACE-obtain.html

Doug
-- 
Dr. Douglas C. Schmidt 			(schmidt@cs.wustl.edu)
Department of Computer Science, Washington University
St. Louis, MO 63130. Work #: (314) 935-4215; FAX #: (314) 935-7302
http://www.cs.wustl.edu/~schmidt/



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

* Re: c++ & pthreads: oil and water ?
  1997-11-12  5:00 ` Douglas C. Schmidt
@ 1997-11-18  5:00   ` Dalibor Carapic
  0 siblings, 0 replies; 4+ messages in thread
From: Dalibor Carapic @ 1997-11-18  5:00 UTC (permalink / raw)



On 12 Nov 1997 17:49:30 -0600, Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> wrote:
>In article <3469D2DB.58D695B9@texas.net>,  <magrasjc@texas.net> wrote:
>++ 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.

There is an article in the CUJ which offered and AThread class and two
derived classes for threads in UNIX (Posix threads) and Windows.
Sorry I can't remember which CUJ it was.

-- 
_______________________________________________________________________
 dcarapic@barok.foi.hr - dalibor.carapic@foi.hr
 Dalibor Carapic - Fakultet Organizacije i Informatike
 http://www.foi.hr/~dcarapic
-----------------------------------------------------------------------



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

* Re: c++ & pthreads: oil and water ?
  1997-11-12  5:00 c++ & pthreads: oil and water ? magrasjc
  1997-11-12  5:00 ` Douglas C. Schmidt
@ 1997-11-18  5:00 ` Jochen Klein
  1 sibling, 0 replies; 4+ messages in thread
From: Jochen Klein @ 1997-11-18  5:00 UTC (permalink / raw)



magrasjc@texas.net wrote:

> first line of ThreadEntry::Invoke's definition header : parse error
> before `::'
[...]
> template <class T> class ThreadEntry    {
[...]
>      static void *                    Invoke(ThreadEntry<T> *);
[...]
> 
> template <class T> void * ThreadEntry::Invoke(ThreadEntry<T> * Target)

did you try:

template <class T> void * ThreadEntry<T>::Invoke(ThreadEntry<T> *
Target)

Jochen



^ 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