~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to docs/examples/jolib/Ref.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*                     __                                               *\
2
 
**     ________ ___   / /  ___     Scala API                            **
3
 
**    / __/ __// _ | / /  / _ |    (c) 2003, LAMP/EPFL                  **
4
 
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
5
 
** /____/\___/_/ |_/____/_/ | |                                         **
6
 
**                          |/                                          **
7
 
\*                                                                      */
8
 
 
9
 
package examples.jolib;
10
 
/*
11
 
import concurrent.SyncVar;
12
 
import concurrent.jolib._;
13
 
 
14
 
class Ref[a](init: a) extends Join {
15
 
  
16
 
  object get extends Synchr[a](this) { case class C() extends SyncVar[a]; }
17
 
  object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; }
18
 
  object state extends Asynchr(this) { case class C(x: a); }
19
 
 
20
 
  rules (
21
 
    Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) =>
22
 
      { g.set(x); state(state.C(x)) } }),
23
 
    Pair(List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
24
 
      { s.set(()); state(state.C(x)) } })
25
 
  );
26
 
 
27
 
  state(state.C(init));
28
 
  
29
 
  def Get: a = get(get.C());
30
 
  def Set(x: a): unit = set(set.C(x));
31
 
}
32
 
*/
33
 
object RefTest {
34
 
 
35
 
  def main(args: Array[String]) = {
36
 
    System.out.println("Started.");
37
 
/*
38
 
    concurrent.ops.spawn({
39
 
      val r1 = new Ref(0);
40
 
      System.out.println("Reference r1 created.");
41
 
      System.out.println("Value r1 (first time) = " + r1.Get);
42
 
      r1.Set(42);
43
 
      System.out.println("Value r1 (second time) = " + r1.Get);
44
 
    });
45
 
    concurrent.ops.spawn({
46
 
      val r2 = new Ref(100);
47
 
      System.out.println("Reference r2 created.");
48
 
      System.out.println("Value r2 (first time) = " + r2.Get);
49
 
      r2.Set(89);
50
 
      System.out.println("Value r2 (second time) = " + r2.Get);
51
 
    });
52
 
*/
53
 
  }
54
 
 
55
 
}