Threading model questions for Eclipse builder developer [message #1803809] |
Mon, 11 March 2019 06:59  |
Eclipse User |
|
|
|
Hello,
I am writing a plugin which includes a builder. I am trying to understand what sort of thread-safety concerns I need to address.
I know that there is a main GUI thread and am also becoming familiar with the "Jobs" facility where it is clear to me that the background task code is running outside the GUI thread.
What I would like to know is when BUILDER code runs during compilation. Specifically my first questions are:
- Since building a project shows up in the progress view, I assume that Eclipse compiles code as a "job" outside the GUI thread. Is that accurate?
- Is it safe to assume that builders run one-at-a-time in sequence in a single job (work thread) that only has to worry about concurrent GUI thread events, or do I need to worry about multiple builders triggering concurrently (e.g. because in a full clean build where projects A and B have no relation to each other - other than being in the same workspace - might get compiled concurrently in separate work threads?
By the way, is this the right forum for "developer" questions or is it supposed to be mostly a "user" forum? Where would I get more traction discussing this sort of thing?
|
|
|
Re: Threading model questions for Eclipse builder developer [message #1803818 is a reply to message #1803809] |
Mon, 11 March 2019 09:11   |
Eclipse User |
|
|
|
Hi Alexandros.
The forums are the right place for this kind of question -- the -dev lists are for the developers working on the implementations of components, not the consumers of those components. That said, if you think you've hit a bug in a component, the -dev list is a good place to check.
The key to the builders is to use the Eclipse locking system, based around ISchedulingRule, and knowing when your code is and is not protected by a scheduling rule. If you're building a standalone builder then it's reasonably straightforward, but if you interact with other components, like M2Eclipse, then you need to respect their scheduling rules too. You should obtain these scheduling rules from an IResourceRuleFactory (such as from `IWorkspace#getRuleFactory()`). Be sure to read over and understand WorkspaceJob and WorkspaceModifyOperation.
Be sure to read the workspace modification and advanced resource docs, and "On the Job: The Eclipse Jobs API".
You might find this helper class helpful in diagnosing deadlock issues.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04353 seconds