Does anybody do pthread and C++ knows how to create a C++ object as a thread
I don't know what exactly are you trying to do. If you want to create an object
within a thread, then you just create it.
If you want to have an object which 'impersonates' a thread (has a function
which runs in a separate thread), then you have to do one of the two things:
Since class member functions (or pointers to them) differ from the regular
functions in that they have to contain a pointer to the actual object plus the
pointer to the member function, you cannot pass such a function to the
You can declare one of the member functions as static, or you can declare an
external function (not a member, just a regular f.) and make it a friend of your
class. In both cases you have to pass the pointer to the actual object as an
argument to your function in pthread_call.
void* theFunction(void* param)
> Does anybody do pthread and C++ knows how to create a C++ object as a thread
> with pthread?
>Does anybody do pthread and C++ knows how to create a C++ object as a thread
\ Real name : Jrgen Heinzl \ no flames /
I'm using rpc on IRIX 6.5, where I have written my own svc_run() loop
that runs in a separate thread to the main UI thread (I've included
the code below).
The problem is, even though I only create the one thread, and I have
confirmed that svc_getreqset() is always called from the same thread,
when I track the current thread in the dispatch function, it is not
always the same - that is, calling svc_getreqset() is somehow causing
the underlying rpc library to create an extra thread! I can't find
anything in any documentation suggesting this should happen, but that
is without doubt what is occurring.
Any help about this would be extremely appreciated!
/// Rpc thread code
void RpcThread(SVCXPRT* xprt)
int msck = xprt->xp_sock;
fd_set sfds = fds;
switch (select(msck + 1, &sfds, 0, 0, 0))
if (FD_ISSET(xprt->xp_sock, &sfds))
int sck = accept(xprt->xp_sock, 0, 0);
svcfd_create(sck, 0, 0);
if (sck > msck)
msck = sck;
2. AIX v5 ???