------art_24138_27667638.1201207969601
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Jan 24, 2008 9:45 PM, daniel éÌerud <daniel.akerud / gmail.com> wrote:

> On Jan 24, 2008 7:45 PM, yermej <yermej / gmail.com> wrote:
>
> > On Jan 24, 9:10 am, daniel éÌerud <daniel.ake... / gmail.com> wrote:
> > > [Note:  parts of this message were removed to make it a legal post.]
> > >
> > > I want to use a DLL with Ruby (Win32). This DLL has X number of
> > functions,
> > > and one of these takes a function pointer. The DLL will call this
> > > callback-function when some data arrives. I cannot figure out how to
> > do this
> > > in Ruby. Is it possible? If not, any tips on how to circumvent this
> > > restriction? _Any_ hints appreciated.
> > >
> > > /D
> >
> > I haven't tried it before, but look into Win32::API::Callback. Most of
> > my googling returned threads where people were having problems with
> > it, but that might give you examples to get started with. Here's one
> > of them:
> > http://rubyforge.org/pipermail/win32utils-devel/2008-January/000985.html
> >
> > Look for where SNMPAPI_CALLBACK is defined. It appears that Callback
> > takes two arguments - the first is the parameter signature notated the
> > same as when you use an API method. The second would be the return
> > signature. Following that is the body of the callback as a block.
> >
> >
> Thanks for the answers,
>
> Today I have been working with creating Ruby extensions, and I got this
> idea: What about I pass a Proc.new object to a method in the extension,
> and when the extension gets a callback from the DLL, it calls the Proc
> object. This would work right? I havn't seen an example of an extension that
> manages a Proc object though and calls it, but if someone says this sounds
> reasonable i'll do this.
>
> /D
>
>
I think this is important in this context: The callback is called from
another thread, i.e. the DLL creates a thread that reads data in the
background, and when data arrives it calls the callback. Would this be a
problem if the Ruby extension calls the Proc object from another thread, and
if so, how to solve it...

/D

------art_24138_27667638.1201207969601--