FYI --- as usual, one can use x10.lang.GlobalRef to ensure that the static fields at all places share a reference to a single object at place 0 (if that's what one wants instead).

class Foo {
   static val myMap = GlobalRef(new HashMap[String,String]());
}

On 5/30/2012 12:17 PM, David P Grove wrote:

tobias.lan...@informatik.stud.uni-erlangen.de wrote on 05/30/2012 08:16:10 AM:

> my question is whether there is the possibility to create
> place specific static objects (or something like that) of a
> class.
> Let's say I have two places "a" and "b" and a class "foo" with
> a static member "bar". When I now call foo.bar from place a,
> I want a different (local) object than by calling foo.bar from
> b.
>

Hi,

In X10, the initialization expression for a static field is evaluated in place 0, and the resulting value is then serialized to all other places. Because objects are copied when serialized, if your static field's initialization expression creates an object this will result in each place having a distinct object stored in its local copy of the static field.

For example

class Foo {
static val myMap:HashMap[String,String] = new HashMap[String,String]();
      }

The myMap field in place N and place M (N != M) will refer to different HashMap objects.


--dave


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to