Sharing data between background thread and clients [message #1491427] |
Sat, 29 November 2014 01:00 |
Andreas Reuter Messages: 2 Registered: November 2014 |
Junior Member |
|
|
Hi everyone,
I am building a RAP application which displays a bunch of data for the user to examine in his browser. This is live data, so it frequently changes. Right now I am using a background thread that is constantly running and, when triggered over the network, will read the newest data from the filesystem. The thread then stores this data in a static datastructure and schedules UI updates for all the clients using Display.asyncExec(). The clients then read the new data from the static datastructure and display it. For thread safety I am using read/write locks to access the data.
So this seems to be working right now, but I feel like this is not an optimal solution. I looked into RAP data stores and found that the application-wide data sharing using the ApplicationContext was a nice fit for my needs. I realized then however, that I cannot access the ApplicationContext from my background thread, only from UISessions (unless I get it by casting my Application object to ApplicationImpl and using the getApplicationContext() method, which is not in the API and seems to be discouraged from use).
I understand that this was a design decision and that casting to ApplicationImpl is a bit of a hack.
So I was wondering, what is the best practice to achieve my goal? My goal is to read data with my background thread, then distribute it to all the UISessions and notify them so they can display it.
Cheers,
Andreas
|
|
|
|
Powered by
FUDForum. Page generated in 0.02639 seconds