I have a program that essentially has two events:
- EventOne: query from a REST API every minutes and get a
number
- EventTwo: show the
number
from EventOne on an LED screen
The dilemma is:
- EventOne's REST API is slow, it might take a few seconds to load
- EventTwo uses LED screen's driver function, it has to be kept running (with perhaps only millisecond-level interval) for the LED screen to refresh fast enough, meaning that I can't get it blocked by a few seconds; otherwise the LED shows broken number.
What I think I need is an async HTTP I/O just like JavaScript's async/await syntax so that I can "pause" my EventOne after firing the HTTP request before I get the number back and run my EventTwo in between. When the async IO is ready, EventOne can be resumed.
Is this something libevent natively support? If not, is there any similar event loop framework that natively supports this?
Note:
- The current program I have uses a multi-threaded model, which works fine. The purpose of this question is to investigate the feasibility of using event loop to achieve the same.