Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Notification when Maketarget is done

A lot of my problems may come from inexperience with threading and Eclipse
jobs.  Here is some partial-code of what I am trying to do.  Can anyone
find fault or have suggestions?

public class BMRuntimeJob extends Job {
   AbstractBuildManagerJob jobToRun;
   ...
   public BMRuntimeJob(AbstractBuildManagerJob job) {
      super(job.getJobName());
      jobToRun = job;
   }

   protected IStatus run(IProgressMonitor monitor) {
      jobToRun.run(monitor);
      return new Status(IStatus.OK, BuildManagerPlugin.getID(), IStatus.OK,
"", null);
   }
}
=======================
public class MakeTargetJob extends AbstractBuildManagerJob {

   IMakeTarget mtJobObject;
   ...
   public void run(IProgressMonitor monitor) {
      try {
         mtJobObject.build(monitor);
      } catch (CoreException e) {
         e.printStackTrace();
      }
   }
}
========================
public class CaptureConsoleJob extends Job {
   ...
   protected IStatus run(IProgressMonitor monitor) {
      BuildConsoleManager consoleManager = (BuildConsoleManager)
CUIPlugin.getDefault().getConsoleManager();
      IDocument consoleDocument =
consoleManager.getConsoleDocument(((IMakeTarget)
job.getJobObject()).getContainer().getProject());
      consoleDocument.get();
      return new Status(IStatus.OK, BuildManagerPlugin.getID(), IStatus.OK,
"Contents acquired", null);
   }
}
=========================
[action code]
final AbstractBuildManagerJob job = (AbstractBuildManagerJob) jobs[i];
Job getConsoleJob = new CaptureConsoleJob("Get " + job.getJobName() + "
Results", job);
Job jobToSchedule = new BMRuntimeJob(job);
jobToSchedule.schedule();
getConsoleJob.setPriority(Job.DECORATE);
getConsoleJob.schedule();

=========================
=========================

In the above partial-code, jobs[i] is an instance of MakeTargetJob.  Any
suggestions on how to get these two jobs to schedule correctly.  In the
current case, getConsoleJob always runs while the MakeTarget from
jobToSchedule is running.

Do I have a hope?

Thanks,

Chad


                                                                           
             Dave Inglis                                                   
             <dinglis@xxxxxxx>                                             
             Sent by:                                                   To 
             cdt-dev-admin@ecl         cdt-dev@xxxxxxxxxxx                 
             ipse.org                                                   cc 
                                                                           
                                                                   Subject 
             11/04/2004 10:20          Re: [cdt-dev] Notification when     
             AM                        Maketarget is done                  
                                                                           
                                                                           
             Please respond to                                             
             cdt-dev@eclipse.o                                             
                    rg                                                     
                                                                           
                                                                           




IProject.build() is documented as long running (blocking), if you are
seeing otherwise maybe its not actually building... The background build
preference would not have any effect when invoking a build at this API
level. Looks like you'll need to dig deeper here.

Dave

cebarne2@xxxxxxxxxxxxxxxxxxx wrote:

> BTW, thanks for the input guys.
>
> I did try the IMaktarget.build() but it seemed to also happen in the
> background (perhaps I should investigate this again).  Looking at the
> implementation of MakeTarget, build uses a WorkspaceRunnable to do its
> work.  It eventually calls project.build() to call the project builder,
> which I assume is also sending the work to the background.
>
> So, regardless of what method I choose to build the MakeTarget, will I
need
> to turn-off the background build preference?
>
> Thanks,
>
> Chad
>
>
>

>              Dave Inglis

>              <dinglis@xxxxxxx>

>              Sent by:
To
>              cdt-dev-admin@ecl         cdt-dev@xxxxxxxxxxx

>              ipse.org
cc
>

>
Subject
>              11/04/2004 09:34          Re: [cdt-dev] Notification when

>              AM                        Maketarget is done

>

>

>              Please respond to

>              cdt-dev@eclipse.o

>                     rg

>

>

>
>
>
>
> TargetBuild.buildTargets will create its own job and based of preference
> setting may return right away (build in background), what you could do
> is build the target your self via IMakeTarget.build() as this will block
> until the build is finished.
>
> Dave
>
> cebarne2@xxxxxxxxxxxxxxxxxxx wrote:
>
>>I just tried join() and it seemed to do nothing to help.
>>
>>    makeTargetJob().schedule();
>>    makeTargetJob().join();
>>    captureConsoleJob().schedule();
>>
>>This seems to do nothing to delay the second job.
>>
>>I've also tried setting priorites and that does nothing as well.
>>
>>I've tried setting rules as follows:
>>
>>    final MutexRule rule = new MutexRule();
>>    makeTargetJob.setRule(rule);
>>    captureConsoleJob.setRule(rule);
>>    makeTargetJob.schedule();
>>    captureConsoleJob.schedule();
>>
>>No luck.  It seems that the makeTargetJob finishes after it calls
>>TargetBuild.buildTargets() , instead of waiting for buildTargets() to
>>complete.
>>
>>Any suggestions?  Being able to wait for a MakeTarget to complete is
>>critical for this plug-in.
>>
>>Thanks,
>>
>>Chad Barnes
>>Rockwell Collins
>>
>>
>>
>
>
>>             Alex Chapiro
>
>
>>             <achapiro@xxxxxxx
>
>
>>             >
>
> To
>
>>             Sent by:                  cdt-dev@xxxxxxxxxxx
>
>
>>             cdt-dev-admin@ecl
>
> cc
>
>>             ipse.org
>
>
> Subject
>
>>                                       Re: [cdt-dev] Notification when
>
>
>>             11/04/2004 08:26          Maketarget is done
>
>
>>             AM
>
>
>
>
>>             Please respond to
>
>
>>             cdt-dev@eclipse.o
>
>
>>                    rg
>
>
>
>
>>
>>
>>
>>Did you try Job.join()?
>>
>>cebarne2@xxxxxxxxxxxxxxxxxxx wrote:
>>
>>
>>
>>>Is there any way to determine when a maketarget is done?  Or, at least
>>>schedule a maketarget to run (using Job.schedule()), and force other
>>>jobs
>>>scheduled afterward to wait until it is complete?  I am working on a
>>>Build
>>>Manager in Eclipse that will allow a user to stack several different
>>>operations (MakeTarget, External Tool, etc) and it will run them in
>>>turn.
>>>MakeTargets are giving me some trouble because I can't seem to get a
>>>Maketarget to run in serial.  It always seems to run in its own parallel
>>>thread.
>>>
>>>I would like to be able to do the following:
>>>
>>>
>>>makeTargetJob.schedule();
>>>captureConsoleJob.schedule();
>>>makeTargetJob2.schedule();
>>>captureConsoleJob2.schedule();
>>>
>>>...and be certain that "captureConsoleJob" will not run before
>>>"makeTargetJob" is finished.
>>>
>>>How do I poll the status of a make target?  Or, how can I make it run in
>>>a
>>>thread of my own design?
>>>
>>>Thanks,
>>>
>>>Chad Barnes
>>>Rockwell Collins Inc.
>>>
>>>_______________________________________________
>>>cdt-dev mailing list
>>>cdt-dev@xxxxxxxxxxx
>>>http://dev.eclipse.org/mailman/listinfo/cdt-dev
>>>
>>>
>>>
>>
>>_______________________________________________
>>cdt-dev mailing list
>>cdt-dev@xxxxxxxxxxx
>>http://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
>>
>>_______________________________________________
>>cdt-dev mailing list
>>cdt-dev@xxxxxxxxxxx
>>http://dev.eclipse.org/mailman/listinfo/cdt-dev
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-dev




Back to the top