V4RB 3.0 and pre-emptive threads
Dave Addey
listmail1 at dsl.pipex.com
Tue Jul 24 03:30:04 CDT 2007
Hi Charles / Ruslan,
Thanks to Charles's code, I'm now up and running with calling Valentina from
the background thread. I have one final question, and it's really an "is
this possible?" question. Here goes...
If I open a database on the main thread, is there a way for me to pass a
reference to it to my V4CC declares? I'm aware that the VDatabase object in
REALbasic is a pointer to a REALobject in the V4RB plugin, and is not a
pointer straight to a valentina database instance. Is there some way I can
pass these between the two? (Likewise for a Vcursor, to be passed back from
my V4CC declares to the REALbasic code on the main thread).
Sorry about this - and thanks for the continued help!
Dave.
> From: Charles Yeomans <charles at declareSub.com>
> Reply-To: Valentina Developers <valentina at lists.macserve.net>
> Date: Mon, 23 Jul 2007 12:23:40 -0400
> To: Valentina Developers <valentina at lists.macserve.net>
> Subject: Re: V4RB 3.0 and pre-emptive threads
>
> Here's the code you need to initialize and shut down V4CC.
>
> const CocoaLib = "Cocoa.framework"
>
> soft declare function NSClassFromString lib CocoaLib (aClassName
> as CFStringRef) as Ptr
> soft declare function NSSelectorFromString lib CocoaLib
> (aSelectorName as CFStringRef) as Ptr
>
> dim NSBundleClass as Ptr = NSClassFromString("NSBundle")
>
> soft declare function objc_msgSend lib CocoaLib (obj as Ptr,
> selectorID as Ptr, param1 as CFStringRef) as Ptr
>
> dim ValentinaBundle as Ptr = objc_msgSend(NSBundleClass,
> NSSelectorFromString("bundleWithPath:"), "/path/to/V4CC.framework")
>
> soft declare sub objc_msgSend lib CocoaLib (obj as Ptr, selectorID
> as Ptr)
>
> objc_msgSend ValentinaBundle, NSSelectorFromString("load")
>
> dim ValentinaClass as Ptr = NSClassFromString("Valentina")
>
>
> soft declare function objc_msgSend lib CocoaLib (obj as Ptr,
> selectorID as Ptr) as Ptr
>
> dim ValentinaObject as Ptr = objc_msgSend(ValentinaClass,
> NSSelectorFromString("instance"))
>
>
> soft declare sub objc_msgSend lib "Cocoa.framework" (obj as Ptr,
> selectorID as Ptr, param1 as Integer, param2 as CFStringRef)
>
> objc_msgSend ValentinaObject, NSSelectorFromString
> ("initWithCacheSize:serial:"), 8*1024*1024, ""
>
>
> objc_msgSend ValentinaObject, NSSelectorFromString("shutDown")
>
>
>
> This code works, but I did not work out memory management carefully;
> probably you should release ValentinaBundle when finished with it.
>
> I'm not sure that you wouldn't be better off either getting V4Rb to
> work with preemptive threads, or studying your SQL to see if you can
> come up with something faster.
>
> Charles Yeomans
>
>
>
>
>
>
>
>
> On Jul 23, 2007, at 11:37 AM, Dave Addey wrote:
>
>> Hi Charles,
>>
>> I've downloaded V4CC, but I'm still not managing to declare against
>> the
>> library. I'm assuming I need to declare against
>> "/Library/Frameworks/V4CC.Framework/V4CC"? How would I go about
>> making a
>> declare for (e.g.) initialising Valentina, or shutting down Valentina?
>>
>> I'm sure that as soon as I get started on this, I'll be good to go
>> - but I'm
>> struggling to get established.
>>
>> Does the same go for declaring against VSDK.Framework?
>>
>> Sorry for the basic questions - I'm generally okay with declares
>> (albeit new
>> to Cocoa ones), but just need some help getting started.
>>
>> Dave.
>>
>>> From: Charles Yeomans <charles at declareSub.com>
>>> Reply-To: Valentina Developers <valentina at lists.macserve.net>
>>> Date: Mon, 23 Jul 2007 10:46:03 -0400
>>> To: Valentina Developers <valentina at lists.macserve.net>
>>> Subject: Re: V4RB 3.0 and pre-emptive threads
>>>
>>> If you want to try this approach, you might be better off getting the
>>> Objective-C library and declaring to that.
>>>
>>>
>>> Charles Yeomans
>>>
>>>
>>> On Jul 23, 2007, at 6:10 AM, Dave Addey wrote:
>>>
>>>> Hi Ruslan,
>>>>
>>>> Thank you for all of the help with this. I have one more
>>>> possibility to
>>>> explore. Would it be possible for me to declare directly against
>>>> the
>>>> Valentina Kernel dylib, and pass in a reference to the Valentina
>>>> objects I
>>>> have already created? Something like this in RB:
>>>>
>>>>
>>>> Const kVKernelLib =
>>>> "/usr/local/lib/vcomponents/libvkernel_fat_release.dylib"
>>>>
>>>> Declare Function ValentinaInit Lib kVKernelLib (inCacheSize as
>>>> UInt32,
>>>> inMacSNPtr as Ptr, inWinSNPtr as Ptr, inUnixSNPtr as Ptr) as UInt32
>>>>
>>>> Dim VCacheSize as integer
>>>> VCacheSize = ValentinaInit(8*1024*1024, 0, 0, 0)
>>>>
>>>>
>>>> Whenever I try this, my REALbasic application crashes with a
>>>> console error
>>>> of:
>>>>
>>>>
>>>> dyld: lazy symbol binding failed: Symbol not found: _ValentinaInit
>>>> Referenced from: /Documents/DJ-1800/svn_code_cvsdude/
>>>> PreemptiveThread/Test
>>>> project/PreemptiveThread.debug.app/Contents/MacOS/
>>>> PreemptiveThread.debug
>>>> Expected in: /usr/local/lib/vcomponents/
>>>> libvkernel_fat_release.dylib
>>>>
>>>>
>>>> This does not involve passing references to existing REALbasic
>>>> objects, and
>>>> I guess I would need to do this too.
>>>>
>>>> I am very aware that this is *not* the way this is meant to be
>>>> done! But I
>>>> have to find a way to call Valentina, on a true, preemptive
>>>> background
>>>> thread from within REALbasic, using my existing REALbasic valentina
>>>> objects,
>>>> but without using the V4RB plugin. My only alternative is to re-
>>>> write all
>>>> of my database code in a plugin (and this is a lot of code).
>>>>
>>>> If you have any other ideas as to how I could do this, I would be
>>>> very
>>>> grateful, as I am hitting my head against a brick wall.
>>>>
>>>
>>> _______________________________________________
>>> Valentina mailing list
>>> Valentina at lists.macserve.net
>>> http://lists.macserve.net/mailman/listinfo/valentina
>>
>>
>> _______________________________________________
>> Valentina mailing list
>> Valentina at lists.macserve.net
>> http://lists.macserve.net/mailman/listinfo/valentina
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
More information about the Valentina
mailing list