[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[ANN] - posixtimer 0.1

Caleb Tennis

12/12/2005 1:04:00 PM


http://rubyforge.org/projects/p...

Here's my first RubyForge release, a small utility that wraps around the POSIX
timer API. This is only available for systems which implement timer_create()
calls - Linux being where I've tested it on.

It's very simple: create a new timer, arm it, and after a certain number of
seconds it will trigger a signal to your application:

timer = Posix::Timer.new
timer.arm(10.0)

# do some stuff for 10 seconds

10 seconds later => SignalException

You can specify a different signal than the default SIGALRM:

Posix::Timer.new("USR1")

or you can pass a block to the initializer and have it executed upon timeout:

a = Posix::Timer.new do
puts "hi"
raise MyCustomException
end

a.arm(10.0)

# 10 seconds later => MyCustomException


Other features:

a.disarm # disarm the timer
a.armed? # true or false
a.timeout # return number of seconds until timer expires



#
# Caveats
#
#
# The Posix::Timer instance uses POSIX signals to trigger
# the timeouts. This may conflict with other signals you wish to
# use in your application.
#
# Passing a block to the constructor will perform a Signal.trap on
# the signal. This may override an existing Signal.trap. In a future
# version I intend to rollback the previous trap context.
#
# Multiple timers using the same signal may conflict.


12 Answers

Joel VanderWerf

12/12/2005 5:59:00 PM

0

Caleb Tennis wrote:
> http://rubyforge.org/projects/p...

I'd be really interested in knowing how this performs compared to simply
using using ruby threads and #sleep (e.g. timeout.rb or similar
mechanisms). In a lightly/moderately/heavily loaded environment, are the
timing errors worse or better? How about reliability? If there are
several posix timers armed, do signals get lost if one handler is
running while another expires?

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Caleb Tennis

12/12/2005 7:58:00 PM

0


> I'd be really interested in knowing how this performs compared to simply
> using using ruby threads and #sleep (e.g. timeout.rb or similar
> mechanisms). In a lightly/moderately/heavily loaded environment, are the
> timing errors worse or better? How about reliability? If there are
> several posix timers armed, do signals get lost if one handler is
> running while another expires?

I have a feeling it's implementation dependent. I'll plan to run a few tests
on it to see what kind of performance I get, though.

Caleb


Sylvain Joyeux

12/12/2005 9:20:00 PM

0

> > How about reliability? If there are
> > several posix timers armed, do signals get lost if one handler is
> > running while another expires?
It depends on the kind of signal used. For posix timers, it is recommended
to use real-time signals, because they are queued.
--
Sylvain Joyeux


Caleb Tennis

12/12/2005 9:35:00 PM

0

> It depends on the kind of signal used. For posix timers, it is recommended
> to use real-time signals, because they are queued.

Yep - I'm working on that for the next release.

Caleb


speechexpert

12/12/2005 9:43:00 PM

0

OK - Here's my issue
My Outlook Expres is getting bogged down by the 50,000 or so emails I have
on Ruby and Rails ml's.
I find searching these lists a valuable source of information.
I tried to search the archives directly, and my impression is the search
engine was slow and unreliable.

How do you all solve this problem, since it must be a common issue.
??

Thanks in advance,

John B




Eero Saynatkari

12/12/2005 9:55:00 PM

0

speechexpert wrote:
> OK - Here's my issue
> My Outlook Expres is getting bogged down by the 50,000 or so emails I
> have
> on Ruby and Rails ml's.
> I find searching these lists a valuable source of information.
> I tried to search the archives directly, and my impression is the search
> engine was slow and unreliable.
>
> How do you all solve this problem, since it must be a common issue.
> ??

Google with the site: parameter.

By the way, it looks like may have committed the dreaded
'thread hijack attack' where you reply to an unrelated
message. This may cause a problem with threading mailreaders
(as well as the archives) so try to avoid it :)

> Thanks in advance,
>
> John B


E

--
Posted via http://www.ruby-....


Bill Guindon

12/12/2005 10:04:00 PM

0

On 12/12/05, speechexpert <speechexpert@sbcglobal.net> wrote:
> OK - Here's my issue
> My Outlook Expres is getting bogged down by the 50,000 or so emails I have
> on Ruby and Rails ml's.
> I find searching these lists a valuable source of information.
> I tried to search the archives directly, and my impression is the search
> engine was slow and unreliable.
>
> How do you all solve this problem, since it must be a common issue.
> ??

Some of us use gmail. It's an excellent way to read lists. Can send
you an invite if you like.

> Thanks in advance,
>
> John B
>
>
>
>


--
Bill Guindon (aka aGorilla)


Gregory Brown

12/13/2005 2:44:00 AM

0

On 12/12/05, Bill Guindon <agorilla@gmail.com> wrote:
> On 12/12/05, speechexpert <speechexpert@sbcglobal.net> wrote:
> > OK - Here's my issue
> > My Outlook Expres is getting bogged down by the 50,000 or so emails I have
> > on Ruby and Rails ml's.
> > I find searching these lists a valuable source of information.
> > I tried to search the archives directly, and my impression is the search
> > engine was slow and unreliable.
> >
> > How do you all solve this problem, since it must be a common issue.
> > ??
>
> Some of us use gmail. It's an excellent way to read lists. Can send
> you an invite if you like.

I use Gmail and generally love it, but two annoying things for anyone
considering using it to view lists:

1) It doesn't thread

2) It sends you a copy of your own messages you've sent, giving the
appearance of double posts.
(unless you set up a filter, then you dont see your posts at ALL

On the good side of things, the search is wonderful and it's very easy
to set up filters for various things. Of course, thunderbird has
good things going for it too, but if you're on many computers in the
course of a day. (I constantly mention that I frequent five different
OSes in the course of a day), having a web based system is great.

You can also search the mailing lists on google groups or ruby-forum.com


Gregory Brown

12/13/2005 2:44:00 AM

0

On 12/12/05, Bill Guindon <agorilla@gmail.com> wrote:
> On 12/12/05, speechexpert <speechexpert@sbcglobal.net> wrote:
> > OK - Here's my issue
> > My Outlook Expres is getting bogged down by the 50,000 or so emails I have
> > on Ruby and Rails ml's.
> > I find searching these lists a valuable source of information.
> > I tried to search the archives directly, and my impression is the search
> > engine was slow and unreliable.
> >
> > How do you all solve this problem, since it must be a common issue.
> > ??
>
> Some of us use gmail. It's an excellent way to read lists. Can send
> you an invite if you like.

I use Gmail and generally love it, but two annoying things for anyone
considering using it to view lists:

1) It doesn't thread

2) It sends you a copy of your own messages you've sent, giving the
appearance of double posts.
(unless you set up a filter, then you dont see your posts at ALL

On the good side of things, the search is wonderful and it's very easy
to set up filters for various things. Of course, thunderbird has
good things going for it too, but if you're on many computers in the
course of a day. (I constantly mention that I frequent five different
OSes in the course of a day), having a web based system is great.

You can also search the mailing lists on google groups or ruby-forum.com


Dick Davies

12/13/2005 4:30:00 PM

0

On 13/12/05, Gregory Brown <gregory.t.brown@gmail.com> wrote:

> I use Gmail and generally love it, but two annoying things for anyone
> considering using it to view lists:
>
> 1) It doesn't thread

Isn't that what a 'conversation' is?

> 2) It sends you a copy of your own messages you've sent, giving the
> appearance of double posts.

only on some lists (this being one of them)

--
Rasputin :: Jack of All Trades - Master of Nuns
http://number9.helloope...