ExecuteSQL() somewhat async?
Eric Forget
forgete at cafederic.com
Thu Jan 30 11:31:11 CST 2003
> on 1/30/03 6:26 AM, Eric Forget at forgete at cafederic.com wrote:
>
>> Hi,
>>
>> After looking for a crash, I found that calling VDK_Cursor::ExecuteSQL()
>> finish by calling OBL_JoinSet_Builder::DoInnerJoinFirstForLink(OBL_Link*,
>> OBL_Object*, OBL_Object*, FBL_BitSet*, FBL_BitSet*) which calls
>> EventAvail(). Is there any reason for this?
>>
>> The problem is that gives the control back to Cocoa who calls me back and
>> now I'm questioning the same VDK_Cursor of the ExecuteSQL() which cause my
>> crash.
>>
>> I know how to go around it but it is cumbersome. Should all my code be
>> reentrant when I use the VSDK? I means which methods of the VSDK calls
>> EventAvail(), WaitNextEvent(), etc. directly or indirectly?
>
> Hi Eric,
>
> In file FBL_ThreadNative.h
> I have function as:
>
> //-------------------------------------------------------
> inline void FBL_ModalYield( void )
> {
> #if !__MACH__
> // Give time to other applications
> EventRecord macEvent;
> ::EventAvail( everyEvent, &macEvent );
> #endif
>
> // Yield to any other thread of this appliation
> FBL_Yield();
> }
> //-------------------------------------------------------
>
>
> As you see I have wrap call ::EventAvail() by macro
> __MACH__
>
> So am I right that for GCC this macro not works ?
>
> I think for now I can simply add
>
>
> #if !__MACH__ && !__CNUC__
>
>
> Agree?
For GCC as for most defines outside Universal Headers and Metrowerks always
assumes that all macros are defined like this:
#define __MACH__
Without any value (so it is always false!).
Your code should look like:
#ifndef __MACH__
// Give time to other applications
EventRecord macEvent;
::EventAvail( everyEvent, &macEvent );
#endif
But this resolve the problem of Mach-O target, not Mac OS X CFM ones. The
problem is that Cocoa is installing timers which are fired when you call
EventAvail(). The same thing may happen with Carbon Events. So it would be
better:
#ifndef __MACH__
if (gVSDKIsNotRunningMacOSX) { // Initialized in ValentinaInit()
// Give time to other applications
EventRecord macEvent;
::EventAvail( everyEvent, &macEvent );
}
#endif
BTW, I suppose you know this about Mac OS X:
"Synchronous File Manager and OT calls on an MP thread yield better
performance than Async calls on Mac OS X" - from
<http://developer.apple.com/carbon/tipsandtricks.html>
Éric
___________________________________________________________________
Eric Forget Cafederic
ForgetE at cafederic.com <http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
More information about the Valentina
mailing list