[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: rb_funcall() Ruby code callback invoked from within a native thread?

Serge Kruppa

10/5/2006 12:14:00 PM

>Without knowing enough about your application, my reaction to your question
>is this: it seems like you have plenty of good code already written in C
>for handling what I assume are requests-for-service that come to you in UDP
>packets. Why not wrap your C code in a Ruby extension (generally an easy
>thing to do) and then have an EventMachine protocol handle simply call your
>C code with the data from the sockets? That way your C code doesn't need to
>know or care that network communications are even involved, and you can
>Ruby to do all the format-massaging, which Ruby is really good at.

> What's the execution profile of your C-code? Does it block locally on
> things like database calls? If so, then you should use EM's patterns for
> deferred execution. If not, then it's real easy and straighforward.

An issue we have is that all our code must run in an embedded Ruby
environment (Active Ruby), packaged as a traditional Windows application
(MFC). Ruby is the hidden jewel inside a fairly standard Windows program. If
I understood your suggestion correctly, the idea would be to layer an
EventMachine on top of our C code already packaged as a Ruby extension. The
EM would act as a UDP event-driven middleware, passing function requests and
responses back and forth between our main Ruby program and the C code? How
do you suggest we interface the EM with the main Ruby program?

Our Ruby program structure is not event driven unfortunately. I did convert
during the night the C native function that invokes the Ruby callbacks to a
simple UDP message send with a specially formatted text string containing
the parameters. The EM receives these UDP callback notifications very
effectively and passes them on to actual Ruby Proc objects for further
processing.

However, taking the example of my unit test suite, I'm using a simple fall
through logic of test cases executed in logical sequence. I found it
impossible to naively insert the EM into my test suite (I'm ashamed to admit
that I tried to run the EM within a Thread, which resulted in the EM
catching only the first UDP callback and missing all the subsequent ones).

Regarding your question about the execution profile of our C code, it is
mostly RPC style: one computer sends a request to another and blocks on a
PThread condition variable until a response is received from the other end
or a timeout occurs. We do have database operations as well, protected by a
series of PThread mutexes.

I have been looking for more information about the EM deferred execution
pattern but did not find any straightforward description. Any pointers to
suitable Web pages would be most appreciated :)






1 Answer

A. Nation

9/2/2013 2:15:00 AM

0

"Denny" is a Socialist-Communist Troll, a moderately retarded fool,
and a poor liar.

From: dzweibach@REMOVEyahoo.com (Denny)
X-No-Archive: yes

----------
Everything you need to know about 'Denny':
>Bret Cahill <BretCahill@peoplepc.com> wrote:
>> Holder needs to go after W. Bush & Cheney for using the IRS against
>> anti-quagmire activists and after they are safely behind bars then
>> we'll discuss Obama.
>...Those two have problems enough. We've all heard the rumors...Screaming
>nightmares, heavy drug use...leave them alone, let them suffer. Every time
>one of them see a Wounded Warrior ad on TV, their handlers have to hit them
>with the needle.
>MAY EVERY WAR-SUPPORTING RIGHT-WINGER SUFFER THE SAME.
[Emphasis mine - PG.]
----------

"Denny" posts a lot like a new version of that old brain-damaged idiot
"Ray Fischer."

Please note that when you reply to a Liar you encourage them to
continue lying.

[][][][][][]
The DemocRATs Hall Of Shame asks "Why do you always LIE?"

[Courtesy of Buster Norris]

On 19 Feb 2013 01:16:13 GMT, dzweibach@REMOVEyahoo.com (Denny) wrote:
>I'll bet WalMart, or their computers, transferred her because they are
>always desperate for experienced employees. They have a 60% per year
>turmonver, and emplyee training is a huge expense.

LIAR!!!!!!!!!!!!!!!!!!!!!!!

"The average retailer has a 60 percent employee turnover rate, meaning
it would need to replace that percentage of its workforce over the
course of a year,..."
http://www.bloomberg.com/news/2010-12-07/wal-mart-to-end-extra-pay-for-sunday-shifts-in-2011-as-duke-targets-...

"...first-year turnover while Wal-Mart's is almost 50 percent."
http://smallbusiness.chron.com/employee-turnover-grocery-...

Posted on behalf of:
The DemocRATs Hall of Shame!