Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Sharing data between background thread and clients
Sharing data between background thread and clients [message #1491427] Sat, 29 November 2014 01:00 Go to next message
Andreas Reuter is currently offline Andreas ReuterFriend
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
Re: Sharing data between background thread and clients [message #1494117 is a reply to message #1491427] Mon, 01 December 2014 07:38 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
try RWT.getUISession( display ).getApplicationContext(). According to
your explanation, you have access to display object in your background
thread.
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:wrong initial line hieght with Nebula Grid
Next Topic:Change Label Image when pressed
Goto Forum:
  


Current Time: Thu Apr 25 09:06:02 GMT 2024

Powered by FUDForum. Page generated in 0.02639 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top