tags:

views:

18

answers:

2

Hi there,

In the context of an IResourceChangeListener I need to modify a given preference file in the workspace. Because of “Note that during resource change event notification, further changes to resources may be disallowed.” the only solution to perform this change is to delay it on a future event (5 seconds later, on the next access to the file to be modified, on the next selection event, etc ..)

I would be interested to know how do you handle such situation ?

A: 

It's very logical to disallow parallel modification. I think this is normal. Furthermore, allowing/disallowing parallel modification is concurrency issue. Hence, this problem is about isolation (ACID).

To handle such situation i will do some text-book workaround which is synchronized, sleep, wait, notify or something similar. In a brief, "the locking thread will notify the waiting thread when he's done". This is abstract but i believe you got the point.

jancrot
+3  A: 

You could make use of the Eclipse Jobs API and its scheduling rules. IResource implements ISchedulingRule, and you can use that to schedule a WorkspaceJob in your resource change listener to run once the lock on the resource (in your case the preference file) is removed.

Zsolt Török
Exactly. Start a WorkspaceJob in your listener and let Eclipse do the rest.
zvikico
@zvikico +1 for your great comment about where exactly to use the job, the way I put it was a bit unclear. I incorporated your comment in my response, if you don't mind.
Zsolt Török