From: "Mats Aubell" <matsemann@c2i.net>
To: <pthreads-win32@sourceware.org>
Subject: Struggling with a loop
Date: Fri, 12 May 2006 14:26:00 -0000 [thread overview]
Message-ID: <20060512142600.MY0VbyFrBndHsxDQWb3ARAn3wK2tVV2tRwAR6kEHfxE@z> (raw)
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
next reply other threads:[~2006-05-12 14:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-12 14:26 Mats Aubell [this message]
2006-05-15 2:18 Will Bryant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060512142600.MY0VbyFrBndHsxDQWb3ARAn3wK2tVV2tRwAR6kEHfxE@z \
--to=matsemann@c2i.net \
--cc=pthreads-win32@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).