1. Michael Granger
  2. ruby-pg
  3. Pull requests

Pull requests

#16 Declined

Use Ruby's GVL for blocking functions

  1. Lars Kanis

This patch adds locking/unlocking the Ruby GVL to blocking function calls of libpq in an unobtrusive way. It is easy extensible to other functions that are not yet wrapped.

Since this patch obsoletes Connection#async_exec and Connection#block for Ruby 1.9, I propose to alias async_exec to exec in case of Ruby 1.9.


  • Learn about pull requests

Comments (3)

  1. Michael Granger repo owner

    First of all: amazing work, as usual. This is clearly something that should be done. The only misgivings I have stem from a mistrust of pre-processor macros that's probably just because I haven't really used them at the level that you're using them in this patch. I'll need to level up a bit in the next few days to understand what you're doing.

    Also, do you have a feeling for how portable these changes are? Are they specific to gcc, or are they reasonable to expect in any environment?

  2. Lars Kanis author

    Thank you for reviewing! Haha, it's just plain C89, nothing fancy, only multi-pass text substitution. I've just verified that it works with Visual-C++ 2008. Linked against libpq, but without Ruby.

    To be honest it was only a try, how far I can come with the preprocessor. But it turned out, that it works quite straightforward (apart maybe from the special treatment of the last function param) and it's reasonably self-explanatory. A code generator written in ruby would be far more flexible, but in this case I don't think it is necessary.