Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Concurrency contract of UI services (Eclipse 3.6.1)
Concurrency contract of UI services (Eclipse 3.6.1) [message #666163] Tue, 19 April 2011 11:25 Go to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
We recently observed in our RCP program that ones in a while we get the
log entry from org.eclipse.ui.internal.services.WorkbenchServiceRegistry
due to the invocation of the loadFromRegistry method:

"Factory already exists for xxxx"

It turned out that this happened, when two different Eclipse jobs
(non-UI Jobs) accessed getSite().getService() from two different views
attempting to get the corresponding service class xxxx at the same time.
We tried to find out whether this was a violation of a user-contract to
work this way with the UI services API, but we could not find a clear
contract in regard to concurrency issues, in particular neither
getSite() nor getService() did provide corresponding constraints. I
might have simply overlooked it, so apologize if this has happened. But
if there is no concurrency contract, this should either be stated
clearly somewhere or the service API would probably expected to be
thread-safe.

I would appreciate any comments before I decide to open a bug report for
this.

Thanks & Greetings from Bremen,

Daniel Krügler
Re: Concurrency contract of UI services (Eclipse 3.6.1) [message #666176 is a reply to message #666163] Tue, 19 April 2011 12:04 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The UI services must all be accessed on the UI thread, unless otherwise
specified. With a few minor exceptions, almost all of our functionality
accessed through parts or the window are not protected against
multi-threaded access (as they're all UI related).

We do sometimes make a case for specific pieces of the workbench to be
thread-safe, like if you were using WorkbenchServiceRegistry to load
non-UI related services. Although there would probably be implications
for IServiceLocator as well.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Concurrency contract of UI services (Eclipse 3.6.1) [message #666184 is a reply to message #666176] Tue, 19 April 2011 12:18 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-04-19 14:04, Paul Webster wrote:
> The UI services must all be accessed on the UI thread, unless otherwise
> specified.

Where can this contract be found? I searched for it, but I could not
find it. Just the fact, that it is named UI services is not convincing
to me.

> With a few minor exceptions, almost all of our functionality
> accessed through parts or the window are not protected against
> multi-threaded access (as they're all UI related).

Don't you think that this should be documented? Please note that I'm not
asking for a IMenuService or any Eclipse-provided service to be
accessible from all threads, I'm asking whether my own services provided
via the UI services extension point to be thread-safe. My implementation
*within* the create-method of the AbstractServiceFactory *is*
thread-safe, so the limiting factor is the extension point infra
structure. I studied the contract of AbstractServiceFactory,
IServiceWithSources, IServiceLocator, and IDisposable, as well as the
description of the org.eclipse.ui.services extension point and no
constraints about concurrency is provided. If the intention is, that
getService must be called from within the UI thread, that should be
documented.

> We do sometimes make a case for specific pieces of the workbench to be
> thread-safe, like if you were using WorkbenchServiceRegistry to load
> non-UI related services. Although there would probably be implications
> for IServiceLocator as well.

How can I load non-UI related services from the WorkbenchServiceRegistry?

Thanks for your quick reply,

- Daniel
Re: Concurrency contract of UI services (Eclipse 3.6.1) [message #666214 is a reply to message #666184] Tue, 19 April 2011 13:18 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/19/2011 08:18 AM, Daniel Krügler wrote:
> Where can this contract be found? I searched for it, but I could not
> find it. Just the fact, that it is named UI services is not convincing
> to me.

It's not specified in the javadoc, it's the way the system works. It's
a hard requirement on the system (as in your break it, the system won't
work correctly). When bugs come up about this, we will issue the
statement in bug (they only work in the UI thread unless otherwise
specified). It is our policy (that would be the Platform UI team).

> Don't you think that this should be documented?

We have a bug about that.

> How can I load non-UI related services from the WorkbenchServiceRegistry?


Technically you can't as the closest you can get is
PlatformUI.getWorkbench() ... which is also bound to the UI thread.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Target platform not being set
Next Topic:JVM terminated.Exit code=-2147483647
Goto Forum:
  


Current Time: Fri Apr 26 06:34:48 GMT 2024

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

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

Back to the top