ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <>
Subject RE: [RESULT] multithrading
Date Wed, 25 Apr 2001 09:05:58 GMT
> From: Siberski, Wolf []
> > Eric Siegerman wrote:
> >
> > You're thinking in terms of telling ant when two things can be
> > done in parallel; it's better to think in terms of telling it
> > when they *can't* be, and letting it default to parallel unless
> > told otherwise.  Like this:
> >
> >     <target name="build" depends="compile,copy_properties"/>
> >
> >     <target name="compile" depends="foo,blat">
> > 	<javac ... />  <!-- compile source -->
> >     </target>
> >
> >     <target name="copy_properties" depends="bar">
> > 	<copy todir="${deploy.dir}" ... />  <!-- copy
> > properties files into the class -->
> >     </target>
> >
> > Looks familiar, no? :-)  Since neither "compile" nor
> > "copy_properties" depends on the other, ant can do them in
> > parallel.  *No* additional syntax is required to say that.
> >
> This is also the reason why there should be no guarantee to
> execute dependent tasks in the order they are declared.
> I'm aware that sometimes You want them to be executed in
> a specific order, but that should not be the default IMHO.
> This way we let the door open to a parallelized target
> execution engine, although I agree this shouldn't be a
> target for 2.0.

Well, the cold reality is that we do give guarantees that things will be
done sequentially. I think we will be breaking lots of builds if we were to
just change that, unfortunately.

Now, there is no reason to just add a little bit more of new syntax to
diferentiate between sequential-exec-required (",") and
sequential-exec-optional (";" for example). So the target in your example
would be written:

	<target name="build" depends="compile;copy_properties"/>

or you could say:

	<target name="build" depends="generate,compile;copy_properties"/>

which means execute "generate" and "compile" ensuring sequential execution,
and "copy_properties" can be done in any order.

Now, notice from my last comment that I have sneekily replaces "parallel" or
"sequentially-optonal" by "any order". That is really what I think is the
right definition. We want writers to be able to say "i do not care about the
order in which you evaluate these dependencies". In a sequential
implementation of ANT, that means that the engine has freedom to choose what
to evaluate. In a parallel engine, that freedom includes parallel execution.

So, how do we do it? It is quite simple. Today, when ANT constructs the DAG
of dependencies, it adds a dependency, not only between the each "target"
and its dependencies, but also between each dependency and the previous
dependency in the ","-separated list (indicating the implicit sequential
requirement). The only change needed is that when one finds the ";" one will
not add the dependency to the previous target in the list.

Now, when sequential ANT selects an order of execution for the targets in
the DAG it has the freedom to pick any order. When there are multiple
choices on the next target, it can even use a random choice to decide what
to do next, so that users do not get ideas about implicit orders :-). For
parallel ANT, it has the right to use aditional engines to execute on
multiple targets at the same time.

The changes are quite simple actually. It would be easy to add even in ANT
1.x 8-)

Jose Alberto

View raw message