summaryrefslogtreecommitdiff
path: root/src/test/smp/separate/library/Counters.smp
blob: a3e36562d58c0123e5b8e89b6ce599e1a4b27171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
// A library can keep shared state and publish instance constructors.
int calls=0;
val next_noInline={ -> calls++; return calls; };

struct Counter {
    val value=1;
    new Counter={int n ->
        value=0;
        for(int i=0; i<n; i++) value=value*2+1;
    };
    val get={ -> value; };
};