Hi. I need to execute a function from within a GUI. This seems to be no problem but this function takes about 4 minutes to finish, which means the application doesn't react at all, while the function is running. Can I execute a function as a separate Thread, while keeping control(e.g. a reference) of it at the same time? If not, how do this with a class containing this function? thanks, stephan <p><p><p>_________________________________________________________________ MSN Groups & Chat - Freunde finden - leicht gemacht http://groups.msn.com/people/ --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
On Sat 11 January 2003 15:17, Spork Michael wrote:> Hi. > I need to execute a function from within a GUI. > This seems to be no problem but this function takes about 4 > minutes to finish, which means the application doesn't react at > all, while the function is running. > Can I execute a function as a separate Thread, while keeping > control(e.g. a reference) of it at the same time? > If not, how do this with a class containing this function?Ehm, how is this Vorbis-related? Or is the function call one that encodes a file? Well anyway, on UNIX in C with POSIX threads, pthread_create() is what you want. Tell more if you want a better answer. Lourens -- GPG public key: http://home.student.utwente.nl/l.e.veen/lourens.key --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Hello Lourens and Hello to you all, we are sorry. Our thread-mail was a copy - shouldn't be in this discussion-group. Thanx, Michael and Stephan <p><p><p><p>>From: Lourens Veen <lourens@rainbowdesert.net>>Reply-To: vorbis-dev@xiph.org >To: vorbis-dev@xiph.org, "Spork Michael" <sporkmichael@hotmail.com> >Subject: Re: [vorbis-dev] Multithreading >Date: Sat, 11 Jan 2003 15:32:44 +0100 > >On Sat 11 January 2003 15:17, Spork Michael wrote: > > Hi. > > I need to execute a function from within a GUI. > > This seems to be no problem but this function takes about 4 > > minutes to finish, which means the application doesn't react at > > all, while the function is running. > > Can I execute a function as a separate Thread, while keeping > > control(e.g. a reference) of it at the same time? > > If not, how do this with a class containing this function? > >Ehm, how is this Vorbis-related? Or is the function call one that >encodes a file? > >Well anyway, on UNIX in C with POSIX threads, pthread_create() is >what you want. Tell more if you want a better answer. > >Lourens >-- >GPG public key: http://home.student.utwente.nl/l.e.veen/lourens.key > >--- >8 ---- >List archives: http://www.xiph.org/archives/ >Ogg project homepage: http://www.xiph.org/ogg/ >To unsubscribe from this list, send a message to >'vorbis-dev-request@xiph.org' >containing only the word 'unsubscribe' in the body. No subject is needed. >Unsubscribe messages sent to the list will be ignored/filtered.<p>_________________________________________________________________ Messenger - Wer in Echtzeit kommunizieren will, lädt den MSN Messenger. Cool, kostenlos und mit 3D Emoticons: http://messenger.msn.de --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Hello. Yes, you can. For my 2nd year Software Engineering workshop back when I was at University, I had to do something similar. The GUI was managed with Motif 1.2 and the application was sound sampling/playback. The sound driver (some hideous contraption designed by Microsoft, no less!) busy-waited on recording and playback, so I had to run that as a separate thread to keep control of my GUI (hitting the "stop" button is a little difficult, otherwise!) :) Bear in mind a few caveats when programming multithreaded applications: a) you need to think 5th-dimensionsionally (parrallelism) when it comes to debugging (your data is SHARED between threads, NOT replicated as with processes spawned via fork() etc!) b) with point a in mind, use POSIX mutexes to arbitrate access to your data (allowing two or more threads to stampede over your data is a recipe for disaster, and then some). Something like pthread_mutex_create() will do the trick. A good book for multithreaded programming is "Multithreaded programming with Pthreads" by Lewis & Berg. This will explain both thread creation with the POSIX thread library - and more importantly, controlling your threads with mutexes. c) make sure all your libraries are MT-safe (multithreaded-safe). Motif 1.2 was *not* - although I have heard since that version 2.2 (check out OpenMotif) is now MT-safe. For non MT-safe libraries, you'll need to sandwich library calls in a mutexlock-call-mutexunlock structure. d) plan it carefully! Software engineering can quite easily turn into a dog's breakfast if you let it, but multithreaded applications are a particularly nasty breed of monster if you let them get out of hand. Don't use so many mutexes that you lose track of them all - but bear in mind that for any useful MT application, they are necessary. Hope this is of some help to you. Kindest regards, Oliver. -----Original Message----- From: owner-vorbis-dev@xiph.org [mailto:owner-vorbis-dev@xiph.org]On Behalf Of Spork Michael Sent: 11 January 2003 14:18 To: vorbis-dev@xiph.org Subject: [vorbis-dev] Multithreading <p>Hi. I need to execute a function from within a GUI. This seems to be no problem but this function takes about 4 minutes to finish, which means the application doesn't react at all, while the function is running. Can I execute a function as a separate Thread, while keeping control(e.g. a reference) of it at the same time? If not, how do this with a class containing this function? thanks, stephan <p><p><p>_________________________________________________________________ MSN Groups & Chat - Freunde finden - leicht gemacht http://groups.msn.com/people/ --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered. --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.