Skip to content

Commit f59f38e

Browse files
committed
Initial commit of an old project that needs some love.
0 parents  commit f59f38e

File tree

14 files changed

+2121
-0
lines changed

14 files changed

+2121
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

pom.xml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>k_k_.concurrent</groupId>
8+
<artifactId>k_k_.concurrent.activate</artifactId>
9+
<version>0.6.0-SNAPSHOT</version>
10+
11+
<name>Activate Library for Scala</name>
12+
<description>
13+
Activate is a Scala Library for Concurrency-Oriented Programming in the
14+
Activity Activation Style.
15+
16+
Copyright (c)2009-2011 by Corbin "Kip" Kohn
17+
All Rights Reserved.
18+
Released under the terms of the Artistic License 2.0
19+
</description>
20+
<inceptionYear>2009</inceptionYear>
21+
<licenses>
22+
<license>
23+
<name>Artistic License 2.0</name>
24+
<url>http://www.opensource.org/licenses/artistic-license-2.0.php</url>
25+
</license>
26+
</licenses>
27+
28+
<properties>
29+
<scala.version>2.7.7.RC2</scala.version>
30+
</properties>
31+
32+
<repositories>
33+
<repository>
34+
<id>scala-tools.org</id>
35+
<name>Scala-Tools Maven2 Repository</name>
36+
<url>http://scala-tools.org/repo-releases</url>
37+
</repository>
38+
</repositories>
39+
40+
<pluginRepositories>
41+
<pluginRepository>
42+
<id>scala-tools.org</id>
43+
<name>Scala-Tools Maven2 Repository</name>
44+
<url>http://scala-tools.org/repo-releases</url>
45+
</pluginRepository>
46+
</pluginRepositories>
47+
48+
<dependencies>
49+
<dependency>
50+
<groupId>org.scala-lang</groupId>
51+
<artifactId>scala-library</artifactId>
52+
<version>${scala.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>junit</groupId>
56+
<artifactId>junit</artifactId>
57+
<version>4.4</version>
58+
<scope>test</scope>
59+
</dependency>
60+
</dependencies>
61+
62+
<build>
63+
<sourceDirectory>src/main/scala</sourceDirectory>
64+
<testSourceDirectory>src/test/scala</testSourceDirectory>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.scala-tools</groupId>
68+
<artifactId>maven-scala-plugin</artifactId>
69+
<executions>
70+
<execution>
71+
<goals>
72+
<goal>compile</goal>
73+
<goal>testCompile</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
<configuration>
78+
<scalaVersion>${scala.version}</scalaVersion>
79+
<args>
80+
<arg>-unchecked</arg>
81+
</args>
82+
</configuration>
83+
</plugin>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-eclipse-plugin</artifactId>
87+
<configuration>
88+
<downloadSources>true</downloadSources>
89+
<buildcommands>
90+
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
91+
</buildcommands>
92+
<additionalProjectnatures>
93+
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
94+
</additionalProjectnatures>
95+
<classpathContainers>
96+
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
97+
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
98+
</classpathContainers>
99+
</configuration>
100+
</plugin>
101+
</plugins>
102+
</build>
103+
<reporting>
104+
<plugins>
105+
<plugin>
106+
<groupId>org.scala-tools</groupId>
107+
<artifactId>maven-scala-plugin</artifactId>
108+
<configuration>
109+
<scalaVersion>${scala.version}</scalaVersion>
110+
</configuration>
111+
</plugin>
112+
</plugins>
113+
</reporting>
114+
</project>
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/**
2+
* Activate Library for Scala - Concurrency-Oriented Programming in the
3+
* Activity Activation Style.
4+
*
5+
* Copyright (c)2009-2011 by Corbin "Kip" Kohn
6+
* All Rights Reserved.
7+
*
8+
* Released under the terms of the Artistic License 2.0; see:
9+
* http://www.opensource.org/licenses/artistic-license-2.0.php
10+
*
11+
*/
12+
package k_k_.concurrent.activate.core
13+
14+
import k_k_.concurrent.activate.loiter._
15+
16+
17+
//!!!!!parse error!!!!!!
18+
// error: identifier expected but ')' found.
19+
// abstract class Activity extends () => Unit
20+
// ^
21+
abstract class Activity extends (() => Unit)
22+
// {
23+
// def unary_~ : Activatom = new Activatom(this)
24+
//}
25+
26+
27+
object Activity {
28+
implicit def func2activity(f: () => Unit): Activity =
29+
new Activity {
30+
def apply() = f()
31+
}
32+
33+
implicit def expr2activity(f: => Unit): Activity =
34+
new Activity {
35+
def apply() = f
36+
}
37+
}
38+
39+
object +> {
40+
def apply(f: => Unit): Activatom =
41+
new Activatom(Non_Guard,
42+
new Activity {
43+
def apply() = f
44+
}
45+
)
46+
}
47+
48+
object ~> {
49+
def apply(f: () => Unit): Activatom =
50+
new Activatom(Non_Guard,
51+
new Activity {
52+
def apply() = f()
53+
}
54+
)
55+
}
56+
57+
/*???
58+
object Activatom {
59+
implicit def activity2activatom(a: Activity): Activatom =
60+
new Activatom(Non_Guard, a)
61+
62+
implicit def expr2activatom(f: => Unit): Activatom =
63+
new Activatom(Non_Guard, new Activity {
64+
def apply() = f
65+
}
66+
)
67+
}
68+
*/
69+
70+
class Activatom(
71+
g: Guard,
72+
act_evts: List[Event],
73+
drop_evts: List[Event],
74+
activities0: List[Activity]
75+
) {
76+
import Activity._
77+
78+
def this(g: Guard, act_evts: List[Event], drop_evts: List[Event],
79+
activity: Activity) =
80+
this(g, act_evts, drop_evts, List(activity))
81+
82+
def this(g: Guard, activity: Activity) =
83+
this(g, Nil, Nil, List(activity))
84+
85+
// def this(activity: Activity) =
86+
// this(Non_Guard, Nil, Nil, List(activity))
87+
88+
//??????????
89+
// error: double definition:
90+
// ...have same type after erasure: (k_k_.concurrent.activate.loiter.guard.Guard,List,List,List)
91+
// def this(g: Guard, act_evts: List[Event], drop_evts: List[Event],
92+
// ^
93+
// activities: List[() => Unit]) =
94+
// this(g, act_evts, drop_evts, activities map {Activity.func2activity(_)})
95+
96+
def this(g: Guard, act_evts: List[Event], drop_evts: List[Event],
97+
activity: () => Unit) =
98+
this(g, act_evts, drop_evts, List[Activity](activity))
99+
100+
def guard: Guard =
101+
g
102+
def activate_events: List[Event] =
103+
act_evts
104+
def drop_events: List[Event] =
105+
drop_evts
106+
def activities: List[Activity] =
107+
activities0
108+
109+
def unary_! =
110+
new Activatom(!g, act_evts, drop_evts, activities0)
111+
def &&(lhs: Guard) =
112+
new Activatom((g && lhs), act_evts, drop_evts, activities0)
113+
def ||(lhs: Guard) =
114+
new Activatom((g || lhs), act_evts, drop_evts, activities0)
115+
def ^ (lhs: Guard) =
116+
new Activatom((g ^ lhs), act_evts, drop_evts, activities0)
117+
118+
def add_activates(acts: List[Event]) =
119+
new Activatom(g, acts ::: act_evts, drop_evts, activities0)
120+
def add_drops(drops: List[Event]) =
121+
new Activatom(g, act_evts, drops ::: drop_evts, activities0)
122+
123+
// def ++^(acts: List[Event]) = add_activates(acts)
124+
def ++^ = add_activates _
125+
126+
// def ++/(drops: List[Event]) = add_drops(drops)
127+
def ++/ = add_drops _
128+
129+
def add_activities(activities_0: List[Activity]) =
130+
new Activatom(g, act_evts, drop_evts, activities_0 ::: activities0)
131+
def add_activities(activity: Activity) =
132+
new Activatom(g, act_evts, drop_evts, activity :: activities0)
133+
/*
134+
def add_activities(activity: () => Unit) =
135+
new Activatom(g, act_evts, drop_evts, activity :: activities0)
136+
137+
def ++&(activity: () => Unit) = add_activities (activity: Activity)
138+
*/
139+
140+
def ++&(activities_0: List[Activity]) = add_activities (activities_0:
141+
List[Activity])
142+
def ++&(activity: Activity) = add_activities (activity: Activity)
143+
144+
//!!!!!!!should redefine all overloaded defs!!!!!!!!
145+
// error: ambiguous reference to overloaded definition,
146+
// ...both method ... and ... match expected type ?
147+
// def ++& = add_activities _
148+
// ^
149+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Activate Library for Scala - Concurrency-Oriented Programming in the
3+
* Activity Activation Style.
4+
*
5+
* Copyright (c)2009-2011 by Corbin "Kip" Kohn
6+
* All Rights Reserved.
7+
*
8+
* Released under the terms of the Artistic License 2.0; see:
9+
* http://www.opensource.org/licenses/artistic-license-2.0.php
10+
*
11+
*/
12+
package k_k_.concurrent.activate.core.eval
13+
14+
import k_k_.concurrent.activate.util.Reverse_Foreach
15+
import k_k_.concurrent.activate.loiter.eval.Event_Observer
16+
import k_k_.concurrent.activate.loiter.eval.Transaction
17+
18+
19+
sealed abstract class Event_Exposition
20+
21+
case class Event_Expectation(
22+
observers: List[Event_Observer]
23+
) extends Event_Exposition with Reverse_Foreach {
24+
25+
def this(observer: Event_Observer) =
26+
this(List(observer))
27+
28+
def add_observer(observer: Event_Observer) =
29+
new Event_Expectation(observer :: observers)
30+
31+
def fulfill(tx: Transaction) = {
32+
// announce existence in reverse order (first, to those waiting longest)
33+
reverse_foreach { (obs: Event_Observer) => obs.exists(tx) } (observers)
34+
}
35+
}
36+
37+
case class Event_Confirmation(
38+
tx: Transaction
39+
) extends Event_Exposition
40+

0 commit comments

Comments
 (0)