niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
· nixdoc.net · man pages · Linux HOWTOs · FreeBSD Tips · Forums
navigation Forum index » Programming » C++
Multithread prob.
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
David
*nix forums Guru


Joined: 19 Feb 2005
Posts: 534

PostPosted: Sun Jul 09, 2006 12:20 pm    Post subject: Multithread prob. Reply with quote

Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
....

startthead(f1); // i tried _beginthread wont work at least...


....
}


}


Thanks.

D.
Back to top
Alf P. Steinbach
*nix forums Guru


Joined: 09 Mar 2005
Posts: 1855

PostPosted: Sun Jul 09, 2006 12:29 pm    Post subject: Re: Multithread prob. Reply with quote

* David:
Quote:

Is it possible in a class' member function to start a thread calling
another member function in the same class

Yes.

Threading is however not yet part of standard C++.


' .....?

Meaningless.


Quote:
.i.e

Incorrect assumption.


Quote:
class A
{
void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...
...
}
}

This code does not compile. See the FAQ on how to post.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Back to top
rami
*nix forums beginner


Joined: 07 Jul 2006
Posts: 9

PostPosted: Sun Jul 09, 2006 12:48 pm    Post subject: Re: Multithread prob. Reply with quote

David wrote:
Quote:
Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...


...
}


}


Thanks.

D.

Most of the thread libraries expect non-member function pointer. You
can get away by making the function static and passing the _this_ ptr
to it.

Ramneek
www.lazybugz.net
Back to top
David
*nix forums Guru


Joined: 19 Feb 2005
Posts: 534

PostPosted: Sun Jul 09, 2006 12:52 pm    Post subject: Re: Multithread prob. Reply with quote

I see. Thanks

D.

"rami" <onewastedlife@gmail.com> wrote in message
news:1152449323.027504.250880@m79g2000cwm.googlegroups.com...
Quote:

David wrote:
Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...


...
}


}


Thanks.

D.

Most of the thread libraries expect non-member function pointer. You
can get away by making the function static and passing the _this_ ptr
to it.

Ramneek
www.lazybugz.net
Back to top
sonison.james@gmail.com
*nix forums beginner


Joined: 10 Jul 2006
Posts: 17

PostPosted: Mon Jul 10, 2006 10:08 am    Post subject: Re: Multithread prob. Reply with quote

Hi,

Try the ACE threading library if you need to use threads in an OO way.
ACE has some neat classes, like ACE_Task which make it quite easy to
use threads in an OO way.

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

Thanks and regards
Sonison James

David wrote:
Quote:
I see. Thanks

D.

"rami" <onewastedlife@gmail.com> wrote in message
news:1152449323.027504.250880@m79g2000cwm.googlegroups.com...

David wrote:
Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...


...
}


}


Thanks.

D.

Most of the thread libraries expect non-member function pointer. You
can get away by making the function static and passing the _this_ ptr
to it.

Ramneek
www.lazybugz.net
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Sun Dec 21, 2014 8:26 am | All times are GMT
navigation Forum index » Programming » C++
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Bad performance multithread jmartin C 6 Mon Jul 10, 2006 8:43 am
No new posts character mode headstart prob. M_Lahlouh Tools 0 Thu Jun 22, 2006 7:38 am
No new posts Weird DMZ PF bridge prob. Anthony Brooks OpenBSD 0 Fri May 19, 2006 5:17 pm
No new posts Multithread Interlocking -- What is wrong with this solui... nde_plume@ziplip.com C++ 4 Fri May 19, 2006 12:44 am
No new posts windows programming prob Shalabh C++ 2 Tue May 09, 2006 7:14 am

Copyright © 2004-2005 DeniX Solutions SRL
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum |  email marketing service
 
Privacy Policy
[ Time: 0.0378s ][ Queries: 16 (0.0035s) ][ GZIP on - Debug on ]