# Ruby/DL loaded shared libraries are blocking?

**URL:** <https://www.ruby-forum.com/t/ruby-dl-loaded-shared-libraries-are-blocking/195503>\
**Category:** Ruby\
**Created:** [September 24, 2010, 12:16am UTC](https://www.ruby-forum.com/t/ruby-dl-loaded-shared-libraries-are-blocking/195503 "2010-09-24T00:16:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PierreW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@PierreW](https://www.ruby-forum.com/u/PierreW)\
**Post date:** [September 24, 2010, 12:16am UTC](https://www.ruby-forum.com/t/ruby-dl-loaded-shared-libraries-are-blocking/195503/1 "2010-09-24T00:16:55Z")

</div>

Hi guys,

I am using Ruby/DL (dl/import) to load a dynamic library. It seems  
that when I call a function of this library from Ruby, it is blocking.  
Is it “normal”, or am I doing something wrong? Is it possible to make  
it non-blocking?

Thanks!  
Pierre

---

<div class="post-metadata">

**Author:** ![PierreW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@PierreW](https://www.ruby-forum.com/u/PierreW)\
**Post date:** [September 27, 2010, 3:57am UTC](https://www.ruby-forum.com/t/ruby-dl-loaded-shared-libraries-are-blocking/195503/2 "2010-09-27T03:57:07Z")

</div>

On Fri, Sep 24, 2010 at 07:05:35AM +0900, PierreW wrote:

> Hi guys,
> 
> I am using Ruby/DL (dl/import) to load a dynamic library. It seems  
> that when I call a function of this library from Ruby, it is blocking.  
> Is it “normal”, or am I doing something wrong? Is it possible to make  
> it non-blocking?

If I’m understanding you correctly, then yes. This is normal. It  
should block until the C function returns.

---

<div class="post-metadata">

**Author:** ![PierreW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@PierreW](https://www.ruby-forum.com/u/PierreW)\
**Post date:** [September 28, 2010, 7:50pm UTC](https://www.ruby-forum.com/t/ruby-dl-loaded-shared-libraries-are-blocking/195503/3 "2010-09-28T19:50:08Z")

</div>

> I am using Ruby/DL (dl/import) to load a dynamic library. It seems  
> that when I call a function of this library from Ruby, it is blocking.  
> Is it “normal”, or am I doing something wrong? Is it possible to make  
> it non-blocking?

Yeah, non blocking (true multi-threading) is considered to introduce  
complexity so it probably default to non true multi-thread.  
I know with jruby this is (probably) not the case, and with ffi you can  
set a method as non blocking, though it appears to have an annoying  
syntax, and would only be non-blocking with MRI 1.9+:  
[http://groups.google.com/group/ruby-ffi/browse\_thread/thread/26440665daf6b519/8f3d9e93fc1025ca?lnk=gst&q=rb\_thread\_blocking\_region#8f3d9e93fc1025ca](http://groups.google.com/group/ruby-ffi/browse_thread/thread/26440665daf6b519/8f3d9e93fc1025ca?lnk=gst&q=rb_thread_blocking_region#8f3d9e93fc1025ca)

-r
