Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Mixing asynchronous data feed with synchronous program flow control

by jcb (Priest)
on Jan 02, 2020 at 04:35 UTC ( #11110859=note: print w/replies, xml ) Need Help??


in reply to Mixing asynchronous data feed with synchronous program flow control

It looks reasonable to me. Process the arriving data in an asynchronous callback and arrange timer events for any synchronous commands that need to be issued, sending the commands in the timer callback. Another option would be to have one process handling both data and commands asynchronously and a synchronous process that talks to that multiplexer and makes the decisions.

Event-driven programming is just messy like this.

  • Comment on Re: Mixing asynchronous data feed with synchronous program flow control

Replies are listed 'Best First'.
Re^2: Mixing asynchronous data feed with synchronous program flow control
by haukex (Chancellor) on Jan 02, 2020 at 09:11 UTC
    Event-driven programming is just messy like this.

    It doesn't have to be, though, it's usually just that it requires more re-thinking of the structure of the code and scoping of variables, and thinking of everything in terms of events - IMHO Your Mother's instinct of "there must be a more elegant solution" was right :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11110859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2020-05-30 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?