Polling vs Event: Behind the API
Posted: Wed Apr 20, 2022 11:25 pm
As an example case, the HUB0000_0's VoltageInput API functionality for Python supports:
- getVoltage(): polling-driven approach
- setOnVoltageChangeHandler(handler): Event-driven approach
The differences between polling and Events are documented here: https://www.phidgets.com/docs/Using_Events
Now, my question is, in the VoltageInput API's backend ("behind the scenes"), how do the two actually work with the hardware?
From the docs, it seems like Phidgets hardware internally uses an Event-driven approach. We can key into new values streaming in via setOnVoltageChangeHandler(handler). Furthermore, the last value streamed in is stored. When one calls getVoltage(), is it:
- Reading from that last stored value
- Perform a round-trip hardware I/O get?
Why do I ask this question?
It's very clear to me that setDataInterval(dataInterval) is closely related with setOnVoltageChangeHandler(handler). However, I am wondering, is setDataInterval(dataInterval) also related to getVoltage()? In other words, does setDataInterval(dataInterval) change the "freshness" of the value returned by getVoltage()?
- getVoltage(): polling-driven approach
- setOnVoltageChangeHandler(handler): Event-driven approach
The differences between polling and Events are documented here: https://www.phidgets.com/docs/Using_Events
Now, my question is, in the VoltageInput API's backend ("behind the scenes"), how do the two actually work with the hardware?
From the docs, it seems like Phidgets hardware internally uses an Event-driven approach. We can key into new values streaming in via setOnVoltageChangeHandler(handler). Furthermore, the last value streamed in is stored. When one calls getVoltage(), is it:
- Reading from that last stored value
- Perform a round-trip hardware I/O get?
Why do I ask this question?
It's very clear to me that setDataInterval(dataInterval) is closely related with setOnVoltageChangeHandler(handler). However, I am wondering, is setDataInterval(dataInterval) also related to getVoltage()? In other words, does setDataInterval(dataInterval) change the "freshness" of the value returned by getVoltage()?