Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

Here is my situation, I have an external program that sends me data every 30 or so ms. That data is merged into a ref.

At this point I have,

(def state (ref {})

a separate future reads and merges packets to this ref.

Now I have my state machine, that is making decisions and sending back control commands. Each state has the following structure,

(while (some-thing-happening)

   (calc-stuff)

   (send-correction))

Here is my problem, if I receive 100 packets/sec there is no point in sending 200 commands/sec. So I would like to come up with a scheme that will throttle the update rate. I can not sleep for some ms cause the update rate is not deterministic. How would you structure this?

1 Answer

0 votes
by (108k points)

The first step is to measure the work so that you can prevent the work while the data is not arriving. After measuring you can model your model as an agent. You can also use a scheme like an agent that will drop any function calls received if it is busy. Or maybe you could add a timestamp to your packets, if they are too old and drop them in the agent.

Browse Categories

...