9 messages in net.java.dev.jna.usersRe: AW: AW: AW: [jna-users] Callback
FromSent OnAttachments
Novatchkov HristoMar 19, 2009 6:59 am 
Timothy WallMar 19, 2009 7:08 am 
Novatchkov HristoMar 19, 2009 8:19 am 
Timothy WallMar 19, 2009 8:52 am 
Novatchkov HristoMar 19, 2009 11:40 am 
Timothy WallMar 19, 2009 1:02 pm 
Novatchkov HristoMar 20, 2009 2:54 am 
Timothy WallMar 20, 2009 5:59 am 
Hristo NovatchkovMar 22, 2009 5:30 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: AW: AW: AW: [jna-users] CallbackActions...
From:Timothy Wall (twal@dev.java.net)
Date:Mar 20, 2009 5:59:26 am
List:net.java.dev.jna.users

The object that your create which implements the Callback interface is associated with a native function pointer, which is passed to the native function which registers the callback. At some future point, the native code will invoke the function pointer, which knows how to transfer control back to Java to the Callback object's callback method.

The specific semantics of what the callback parameters mean, or other parameters used when registering the callback, depend on the native API.

On Mar 20, 2009, at 5:55 AM, Novatchkov Hristo wrote:

I understand the general idea, though, the actual realization for such callback issues is not clear to me. In general, I'm still trying to understand what exactly happens when I call the method with one of the parameters creating a new callback object and also defining the callback method. For example is that parameter always executed (and thus a new callback object created)? Or just if there was some data received? But what happens if there is no data and the method is called?

-----Ursprüngliche Nachricht----- Von: Timothy Wall [mailto:twal@dev.java.net] Gesendet: Donnerstag, 19. März 2009 21:03 An: use@jna.dev.java.net Betreff: Re: AW: AW: [jna-users] Callback

I mean you have to keep a live reference to it. Whether that's in a class static variable or an instance field on an object you know won't be GC'd or something else doesn't really matter.

On Mar 19, 2009, at 2:40 PM, Novatchkov Hristo wrote:

By keeping a reference of the callback object, you mean that one has to define a global variable, which should then reference the aucResponseBuf Memory object (in my case that would happen in the second switch)? So something like:

//global class definition Memory save; ... //callback function definition ... // switch(ucChannel) save = aucResponseBuf; ...