views:

29

answers:

1

Hi:I want to design a structure for letting sensor data ( 3 float values at around ~40Hz) be accessible through something like an Observable. But by using the java Observable/Observer class a high overhead will affect the performance. What are the known approaches to keep it efficient and make it structured as well?

A: 

The 'overhead' of using an Observable interface is very small, and even at 40Hz is probably not going to impact performance. I strongly recommend trying it to see what the performance is like.

One issue is that the java.util.Observable class simply tells the observer that a change has taken place, forcing the Observer to go and get the data. This might be considered a performance degradation if getting the information about of the Observable takes time. You might want to implement your own variant on Observable in which the new data is passed to each Observer as an argument to the notification call.

DJClayworth