Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFRunLoop



Hello,
I came over from the usb list / darwin userlevel cause at the moment I
have problems with CFRunLoops driving my
usb stuff.

In this main :

...
//I create a pthread
err = pthread_create(&PIOSartear.p_thread, NULL, &tloop,
&PIOSartear);
// and that thread stores its GetCurrentRunLoop() in the
PIOSartear.runloop var
// (thread function follows below)
...
while (!err)
{
for (i=0;i<count;i=i+1)
{
err = usbstartta(& PIOSusbdmx[i]); /* zero base use,
starts usb ta */
// this one issues a usb async request
if (err) break; /* start ta might fail */
CFRunLoopRun(); /* CFRunLoopStop(GetCurrent) called by
callback else no
return to here cause cfSource still in place */
// in this async call back the runloop is stopped
// this works fine and the for/while goes on
};
}
...
//being out of my main loop I want to stop the threads runloop
CFRunLoopStop( PIOSartear.runloop ); /* stop the runloop of the
thread */
//-----this does not work at all ????????
...
//before I cancel the thread with a pthread_cancel (which works).



In the pthread I do :

...
(*it).runloop = CFRunLoopGetCurrent();
// store the runloop ref first
// It's a get so I do not call retain cause its my copy (CF*Get* naming
convention)

...
//properly add a socket as cfSource to this (the threads' runloop)
CFRunLoopAddSource(CFRunLoopGetCurrent(), socketcfsource,
kCFRunLoopDefaultMode);
// which also adds a third thread ?? I read nothing about this ...
// sidenote : All CFGets give a ref which has to be Released... how to
do this here ???

...
//properly add a timer
CFRunLoopAddTimer( CFRunLoopGetCurrent(), sectimer,
kCFRunLoopDefaultMode );
...
CFRunLoopRun();
// and run the threads run loop
// At some point in the mains thread I issue the stop call and all of
the below never is
// printed (which I see eqaul to not being processed)

printf("\n out runloop thread\n");

CFRunLoopTimerInvalidate( sectimer );
CFRelease( sectimer );

CFRunLoopRemoveSource(CFRunLoopGetCurrent(), socketcfsource,
kCFRunLoopDefaultMode);
CFRelease( socketref );

close((*it).Socket);
...
while the printfs of the main thread get printed after the call to
CFRunLoopStop.


Any ideas what is going wrong ?


--
Hado Hein, Berlin, Fed.Rep. of Germany

http://HadoH.bei.t-online.de (stage lighting profession)
http://www.batchmaker.de (software authoring, including stage lighting)
_______________________________________________
darwin-drivers mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-drivers
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.