From: Robert Klemme Date: 2013-04-08T18:31:00+09:00 Subject: Re: Mapping string data ptr to buffer in ffi --047d7b6da1d22d7e2204d9d61860 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Apr 8, 2013 at 11:22 AM, se gm wrote: > > I think a better way would be to implement a Ruby class in C and provide > > the information via a getter method which returns a new Ruby String and > > internally uses proper synchronization to maintain thread safety. > It would be too slow, the purpose is to avoid any extra operations (no > memory copy operations at all, the string changes should be immediately > visible in Ruby) regardless of thread safety issues, no setters or > getters. > If you simply change a String's content from some other thread no piece of Ruby code will be aware of this so nothing can really do something with that changed content in Ruby land. You need a method call, either from Ruby side (i.e. when it needs the data) or from the extension side (i.e. after every update). If you do it from the extension side things get more complicated since you need to pass in a Ruby object as callback plus ensure that the calling thread is a Ruby interpreter thread. Btw, what are you trying to create here? Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --047d7b6da1d22d7e2204d9d61860 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


Btw, what a= re you trying to create here?

Cheers

robert

--
remember.guy do |as, often| a= s.you_can - without end
h= ttp://blog.rubybestpractices.com/ --047d7b6da1d22d7e2204d9d61860--