开发者

Modify a file in response to IResourceChangeListener

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 开发者_Python百科be interested to know how do you handle such situation ?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜