Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
e7c8bc4a
Commit
e7c8bc4a
authored
Aug 31, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed actor hierarchy causing akka to not terminate correctly
parent
fb932862
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
benchmarks/scala/MixedCase.scala
benchmarks/scala/MixedCase.scala
+6
-5
No files found.
benchmarks/scala/MixedCase.scala
View file @
e7c8bc4a
...
...
@@ -6,6 +6,7 @@ import scala.actors.Actor
import
scala.actors.Actor._
import
akka.actor.
{
Props
,
Actor
=>
AkkaActor
,
ActorRef
=>
AkkaActorRef
,
ActorSystem
}
import
scala.annotation.tailrec
import
System.out.println
case
class
Token
(
value
:
Int
)
case
class
Init
(
ringSize
:
Int
,
initialTokenValue
:
Int
,
repetitions
:
Int
)
...
...
@@ -166,13 +167,13 @@ class AkkaChainLink(next: AkkaActorRef) extends AkkaActor {
}
}
class
AkkaChainMaster
(
supervisor
:
AkkaActorRef
)
extends
AkkaActor
{
class
AkkaChainMaster
(
supervisor
:
AkkaActorRef
,
system
:
ActorSystem
)
extends
AkkaActor
{
val
worker
=
context
.
actorOf
(
Props
(
new
AkkaWorker
(
supervisor
)))
@tailrec
final
def
newRing
(
next
:
AkkaActorRef
,
rsize
:
Int
)
:
AkkaActorRef
=
{
if
(
rsize
==
0
)
next
else
newRing
(
context
.
actorOf
(
Props
(
new
AkkaChainLink
(
next
))),
rsize
-
1
)
else
newRing
(
system
.
actorOf
(
Props
(
new
AkkaChainLink
(
next
))),
rsize
-
1
)
}
def
initialized
(
ringSize
:
Int
,
initialTokenValue
:
Int
,
repetitions
:
Int
,
next
:
AkkaActorRef
,
iteration
:
Int
)
:
Receive
=
{
...
...
@@ -204,7 +205,7 @@ class AkkaChainMaster(supervisor: AkkaActorRef) extends AkkaActor {
class
AkkaSupervisor
(
numMessages
:
Int
)
extends
AkkaActor
{
var
i
=
0
def
inc
()
{
i
+=
1
;
i
=
i
+
1
if
(
i
==
numMessages
)
{
global
.
latch
.
countDown
context
.
stop
(
self
)
...
...
@@ -212,7 +213,7 @@ class AkkaSupervisor(numMessages: Int) extends AkkaActor {
}
def
receive
=
{
case
Factors
(
f
)
=>
global
.
checkFactors
(
f
);
inc
case
MasterExited
=>
inc
case
MasterExited
=>
println
(
"master exited"
);
inc
}
}
...
...
@@ -233,7 +234,7 @@ class MixedCase(numRings: Int, ringSize: Int, initToken: Int, reps: Int) {
val
system
=
ActorSystem
();
val
s
=
system
.
actorOf
(
Props
(
new
AkkaSupervisor
(
numMessages
)))
for
(
_
<-
0
until
numRings
)
system
.
actorOf
(
Props
(
new
AkkaChainMaster
(
s
)))
!
initMsg
system
.
actorOf
(
Props
(
new
AkkaChainMaster
(
s
,
system
)))
!
initMsg
import
System.out.println
println
(
"awaiting latch"
)
global
.
latch
.
await
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment