From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10443 invoked by alias); 12 May 2006 14:26:06 -0000 Received: (qmail 10431 invoked by uid 22791); 12 May 2006 14:26:05 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out2.blueyonder.co.uk (HELO smtp-out2.blueyonder.co.uk) (195.188.213.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 12 May 2006 14:26:03 +0000 Received: from [172.23.170.140] (helo=anti-virus02-07) by smtp-out2.blueyonder.co.uk with smtp (Exim 4.52) id 1FeYae-0000Fy-8r for pthreads-win32@sourceware.org; Fri, 12 May 2006 15:26:00 +0100 Received: from [82.41.235.177] (helo=matsemann) by asmtp-out5.blueyonder.co.uk with esmtp (Exim 4.52) id 1FeYab-0006ZO-Fe for pthreads-win32@sourceware.org; Fri, 12 May 2006 15:25:59 +0100 From: "Mats Aubell" To: Subject: Struggling with a loop Date: Fri, 12 May 2006 14:26:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2006/txt/msg00017.txt.bz2 Message-ID: <20060512142600.MY0VbyFrBndHsxDQWb3ARAn3wK2tVV2tRwAR6kEHfxE@z> 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