public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* Re: Struggling with a loop
@ 2006-05-15  2:18 Will Bryant
  0 siblings, 0 replies; 2+ messages in thread
From: Will Bryant @ 2006-05-15  2:18 UTC (permalink / raw)
  To: pthreads-win32

Mats Aubell wrote:
> I tried to pass it like this:
>
> pthread_create(&thread, NULL, RunApplication, (void*)top)
>
> with the following method:
>
> void * RunApplication(void * arg)
> {
> 	SR *top = SR*(arg);
> 	StartRecogniser();
> 	do {
> 		top->Ask();	
> 		top->Reset();
> 	} while(1);
> 	return 0;
> }
>
> but the create thread method didn't approve of it. 
>
>   
Can you give us a bit more to go on here - what error does it produce?

-- 
Will Bryant


^ permalink raw reply	[flat|nested] 2+ messages in thread
* Struggling with a loop
@ 2006-05-12 14:26 Mats Aubell
  0 siblings, 0 replies; 2+ messages in thread
From: Mats Aubell @ 2006-05-12 14:26 UTC (permalink / raw)
  To: pthreads-win32

Hi all (again)

One problem solved and three spawn, that's usually how things work. I've
been messing around with pthread, but I'm stuck at the final problem which
hopefully will solve everything. My code is something like this:

Class SR

main 
{
SR *top = new SR();
Method()
Method()
do {
	top->Ask();	
	top->Reset();
} while(1);
}

I want the do-while loop to go in its own thread. I've tried several things,
like putting it into a method like this:

void * RunApplication(void * arg)
{
	SR *top = new SR();
	StartRecogniser();
	do {
		top->Ask();	
		top->Reset();
	} while(1);
	return 0;
}

And calling it with this:

pthread_create(&thread, NULL, RunApplication, NULL)

but it wouldn't go past the SR *top = new SR();

I tried to pass it like this:

pthread_create(&thread, NULL, RunApplication, (void*)top)

with the following method:

void * RunApplication(void * arg)
{
	SR *top = SR*(arg);
	StartRecogniser();
	do {
		top->Ask();	
		top->Reset();
	} while(1);
	return 0;
}

but the create thread method didn't approve of it. 

The RunApplication() works fine when I'm not calling it through the
pthread_create, but I need it to run in it's own thread.

As you can tell, my C++ skills aren't exactly top notch and I've not done
threads on anything but Java so I'm struggling quite a bit. Any feedback
would be of tremendous help, I'm nearing desperation with this.

Cheers,
Mats Aubell


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

end of thread, other threads:[~2006-05-15  2:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-15  2:18 Struggling with a loop Will Bryant
  -- strict thread matches above, loose matches on Subject: below --
2006-05-12 14:26 Mats Aubell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).