Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-debug-dev] Launching with background build


Hello,

I am planning on soon releasing new platform support for background autobuild.  I have been self-hosting on this for a few weeks, and one area that doesn't run very smoothly is launching.  Here is one scenario:

- Autobuild is on, background build enabled.
- User starts a background CVS checkout operation.  Say it's a slow connection and it takes a few minutes.
- While waiting, the user continues to do some work, modifying and saving a java file
- The save operation completes because it is orthogonal to the checkout (operating on disjoint set of resources)
- The subsequent build cannot proceed, because building requires write access to all projects
- The user then launches a debug VM that involves the changed class
- Since the build has not run, the launched VM will operate on stale .class files

One possible solution is to wait for the auto-build to complete before launching.  This can be accomplished using the job manager's join method, which allows a thread to join a running job:

Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);

The problem is, this will now block the launch from proceeding, possibly for several minutes until the checkout completes.  A fancier solution would be to detect that the auto-build is blocked, and then give the user the option to proceed anyway.  You can determine that a job is blocked by seeing if it is in the waiting state (this is pseudo-code, I haven't test it):

Job[] build = Platform.getJobManager().find(ResourcesPlugin.FAMILY_AUTO_BUILD);
if (build.length == 1) {
   if (build[0].getState() == Job.WAITING) {
       //auto-build is blocked by another process, so ask the user if they want to launch or wait
   } else if (build[0].getState() == Job.RUNNING) {
       //auto-build is running, so join it to wait until it completes
      build[0].join();
   }
}

That way the user can choose to launch without building.  If they know they have not made any changes that will affect the running program, they will want to proceed without waiting.

Let me know your thoughts on this.

More info on the platform changes can be found here (doc timelines are outdated):

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-core-home/documents/plan_concurrency_listeners.html

Background build can currently be enabled with the following debug .options:

org.eclipse.core.resources/debug=true
org.eclipse.core.resources/build/background="">

(background build is broken in I20030916, but should be fixed for tomorrow)

John.

Back to the top