views:

454

answers:

2

Does anyone knows if perl supports a task scheduler?

I am working on a c# program that controls a bunch of perl scripts. The perl script talked to some device over the socket interface. The device, "target" , is a embedded system device that require real time interaction.

One of the requirements I need to fulfill is that when I receive message "A" from the device, I need to schedule an event that is going to happen in 15 miliseconds in the future. This event is going to send the message to UT. We call it "B" here. The delay function wouldn't work here because other messages shouldn't be blocked because of Message "B". Sometimes, I also need to send Message "B" every 15 miliseconds.

or Maybe Perl is not a good choice here.

Thanks

+12  A: 

There are several event-driven non-blocking frameworks available for Perl. Any one of them should be able to do what you need. Here are three examples to get you started: POE, AnyEvent, and IO::Async. That said, if you timing constraints are rigorous ("15 milliseconds on the nose, every time"), then a real-time-scheduled program in a lower-level language like C is probably more appropriate.

John Siracusa
Don't forget the need for a real-time kernel, too.
tsee
A: 

Use right tool for right thing. I would strongly recommend you to don't use Perl for this sort of tasks. If you use for example Erlang for this task you will just do this in pure Erlang (just language core, not any module/library):

receive
  {Device, "A"} -> spawn(fun() -> send_interval(15, UT, "B") end)
end

send_interval(Interval, Dest, Msg) ->
  receive after Interval ->
      send_interval(Interval, Dest, Dest ! Msg)
  end.

or using timer module

receive
  {Device, "A"} -> timer:send_interval(15, UT, "B")
end

It is magnitude more reliable and simpler what you can achieve in Perl. It's what I can recommend you after seven years daily professional developing in Perl.

Hynek -Pichi- Vychodil