Subject: Re: [linux-audio-dev] problems creating/managing pthread stuff (audio-app related)
From: Paul Davis (pbd_AT_Op.Net)
Date: Wed Nov 21 2001 - 22:03:10 EET
[ pthread cry for help ... ]
1) buy a good book on programming with threads. i happen to like
"Programming with Threads" by Kleiman, Shah & Smaalders, but there
are others. You'll need it.
2) general method for using C++ objects when starting threads:
class Foo {
public:
static void *function_called_by_thread (void *arg) {
((Foo *) arg)->actual_function_for_thread_to_run ();
}
private:
void *actual_function_for_thread_to_run ();
};
pthread_t thread_id;
Foo *myfoo;
if (pthread_create (&thread_id, 0,
Foo::function_called_by_thread, myfoo) != 0) {
... error: cannot create thread ...
}
At this point, there is a new thread executing
Foo::function_called_by_thread(), which in turn will call
Foo::actual_function_for_thread_to_run().
Hope this helps.
--p
This archive was generated by hypermail 2b28 : Wed Nov 21 2001 - 21:56:53 EET