I just wrote some code, which uses a common master-slave pattern.
Some computation is pushed to all slaves (in other places), which use
different data to work on. My idea was to store this data in a wrapper
in a static field. The wrapper AlwaysLocal (see below) gives out the
local data to every computation.
Isn't this a common pattern? Is there already something in X10 (syntax
or stdlib) to make AlwaysLocal unnecessary?
/* Gives every accessor a local element */
class AlwaysLocal[T] {
val state:Array[T](1);
def this(init:()=>T) {
state = new Array[T](Place.MAX_PLACES);
finish for (p in Place.places()) async {
state.set(init(), p.id);
}
}
def apply():T {
return state(here.id);
}
}
The AlwaysLocal implementation above assumes a flat places structure and
the ids to be [0..]. Thus, it is something, which has to evolve with
changes in the language.
--
Andreas Zwinkau
Karlsruhe Institute of Technology (KIT)
Institut für Programmstrukturen und Datenorganisation (IPD)
Lehrstuhl Prof. Snelting
Adenauerring 20a
76131 Karlsruhe
Phone: +49 721 608-8351
Fax: +49 721 608-8457
Email: [email protected]
Web: http://pp.info.uni-karlsruhe.de/person.php?id=107
KIT – University of the State of Baden-Wuerttemberg and
National Research Center of the Helmholtz Association
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users