Subject: Re: [linux-audio-dev] basic help needed with programming threads
From: Paul Davis (pbd_AT_Op.Net)
Date: Thu May 03 2001 - 05:06:11 EEST
>I'm stuck at a point that needs a threads code block. Here's where I'm
>sticking:
>
> extern "C" void FL_run(FLRUN *p)
> {
> #ifdef _WINDOWS
> threadHandle = _beginthread(fltkRun, 0, NULL);
> if (isActivatedKeyb)
> threadHandle = _beginthread(fltkKeybRun, 0, NULL);
> #elif defined( LINUX ) || defined(someotherUNIXes)
> // create a new thread in the proper way here
> #endif
> }
this should get you started:
pthread_t thread_handle;
void *fltkRun (void *arg);
extern "C" void FL_run (FLRUN *p)
{
#ifdef WINDOWS
#warning blech
#endif
#ifdef LINUX
if (pthread_create (&threadHandle, 0, fltkRun, p)) {
... error ... thread not created ...
}
#endif
}
at this time, you have a thread that has called fltkRun with the FLRUN
pointer as its argument (cast to void *). it will run until
that function returns, or pthread_exit() or exit() or pthread_cancel()
are successfully called.
for prototype reasons, you may need to wrap the real fltkRun function
in a wrapper to make it match the demands of pthreads.
--p
ps. i don't see where gabriel passes the FLRUN pointer to his windows
thread, but i guess it can look up in the registry, and then check
with microsoft.com if its NULL :)
This archive was generated by hypermail 2b28 : Thu May 03 2001 - 05:38:57 EEST