Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Summa Actors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Numerical_Simulations_Lab
Actors
Summa Actors
Commits
b6e0281b
Commit
b6e0281b
authored
2 years ago
by
KyleKlenk
Browse files
Options
Downloads
Patches
Plain Diff
Created structure to hold actors
parent
9f05b702
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/source/actors/OutputManager.h
+56
-3
56 additions, 3 deletions
build/source/actors/OutputManager.h
build/source/testing/testing_main.cc
+103
-3
103 additions, 3 deletions
build/source/testing/testing_main.cc
with
159 additions
and
6 deletions
build/source/actors/OutputManager.h
+
56
−
3
View file @
b6e0281b
...
...
@@ -46,6 +46,10 @@ class ActorRefList {
return
actor
;
}
bool
isEmpty
()
{
return
list
.
empty
();
}
...
...
@@ -55,16 +59,65 @@ class OutputManager {
private:
int
numVectors
;
std
::
vector
<
std
::
vector
<
caf
::
actor
>>
a
ctorRefList
;
int
avgSizeOfActorList
;
std
::
vector
<
A
ctorRefList
*>
list
;
public:
// Constructor
OutputManager
(){}
OutputManager
(
int
numVectors
,
int
totalNumActors
){
this
->
numVectors
=
numVectors
;
int
sizeOfOneVector
=
totalNumActors
/
numVectors
;
this
->
avgSizeOfActorList
=
sizeOfOneVector
;
// Create the first n-1 vectors with the same size
for
(
int
i
=
0
;
i
<
numVectors
-
1
;
i
++
)
{
auto
refList
=
new
ActorRefList
(
sizeOfOneVector
);
totalNumActors
=
totalNumActors
-
sizeOfOneVector
;
list
.
push_back
(
refList
);
}
// Create the last vector with size however many actors are left
auto
refList
=
new
ActorRefList
(
totalNumActors
);
list
.
push_back
(
refList
);
}
// Deconstructor
~
OutputManager
(){};
void
addActor
(
caf
::
actor
actor
,
int
index
)
{
// Index has to be subtracted by 1 because Fortran array starts at 1
int
listIndex
=
(
index
-
1
)
/
this
->
avgSizeOfActorList
;
if
(
listIndex
>
this
->
numVectors
-
1
||
listIndex
<
0
)
{
throw
"List Index Out Of Range"
;
}
this
->
list
[
listIndex
]
->
addActor
(
actor
);
}
caf
::
actor
popActor
(
int
index
)
{
if
(
index
>
this
->
numVectors
-
1
||
index
<
0
)
{
throw
"List Index Out Of Range"
;
}
else
if
(
this
->
list
[
index
]
->
isEmpty
())
{
throw
"List is Empty, Nothing to pop"
;
}
return
this
->
list
[
index
]
->
popActor
();
}
bool
isFull
(
int
listIndex
)
{
if
(
listIndex
>
this
->
numVectors
-
1
)
{
throw
"List Index Out Of Range"
;
}
return
this
->
list
[
listIndex
]
->
isFull
();
}
int
getSize
(
int
listIndex
)
{
if
(
listIndex
>
this
->
numVectors
-
1
)
{
throw
"List Index Out Of Range"
;
}
return
this
->
list
[
listIndex
]
->
getCurrentSize
();
}
};
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
build/source/testing/testing_main.cc
+
103
−
3
View file @
b6e0281b
...
...
@@ -9,7 +9,6 @@
using
namespace
caf
;
behavior
test_coordinator
(
stateful_actor
<
test_state
>*
self
)
{
aout
(
self
)
<<
"Starting Test Actor
\n
"
;
return
{
};
}
...
...
@@ -94,7 +93,7 @@ void test_calculateTime() {
}
void
test
OutputManager
(
caf
::
actor_system
&
sys
)
{
void
test
ActorRefList
(
caf
::
actor_system
&
sys
)
{
auto
a1
=
sys
.
spawn
(
test_coordinator
);
auto
a2
=
sys
.
spawn
(
test_coordinator
);
auto
a3
=
sys
.
spawn
(
test_coordinator
);
...
...
@@ -144,21 +143,122 @@ void testOutputManager(caf::actor_system& sys) {
std
::
cerr
<<
msg
<<
std
::
endl
;
IS_TRUE
(
om
->
getCurrentSize
()
==
0
)
}
}
void
testOutputManager
(
caf
::
actor_system
&
sys
)
{
auto
a1
=
sys
.
spawn
(
test_coordinator
);
auto
a2
=
sys
.
spawn
(
test_coordinator
);
auto
a3
=
sys
.
spawn
(
test_coordinator
);
auto
a4
=
sys
.
spawn
(
test_coordinator
);
auto
a5
=
sys
.
spawn
(
test_coordinator
);
auto
a6
=
sys
.
spawn
(
test_coordinator
);
auto
a7
=
sys
.
spawn
(
test_coordinator
);
auto
a8
=
sys
.
spawn
(
test_coordinator
);
auto
a9
=
sys
.
spawn
(
test_coordinator
);
auto
a10
=
sys
.
spawn
(
test_coordinator
);
auto
OM
=
new
OutputManager
(
5
,
10
);
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
IS_TRUE
(
OM
->
getSize
(
i
)
==
0
)
}
try
{
OM
->
getSize
(
8
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
OM
->
addActor
(
a1
,
1
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a2
,
2
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a3
,
3
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a4
,
4
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a5
,
5
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a6
,
6
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a7
,
7
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a8
,
8
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a9
,
9
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
1
);
IS_TRUE
(
!
OM
->
isFull
(
4
))
OM
->
addActor
(
a10
,
10
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
2
);
IS_TRUE
(
OM
->
isFull
(
0
))
IS_TRUE
(
OM
->
isFull
(
1
))
IS_TRUE
(
OM
->
isFull
(
2
))
IS_TRUE
(
OM
->
isFull
(
3
))
IS_TRUE
(
OM
->
isFull
(
4
))
auto
a11
=
OM
->
popActor
(
0
);
IS_TRUE
(
a11
==
a2
);
auto
a14
=
OM
->
popActor
(
0
);
IS_TRUE
(
a14
==
a1
);
auto
a12
=
OM
->
popActor
(
1
);
IS_TRUE
(
a12
==
a4
);
auto
a13
=
OM
->
popActor
(
4
);
IS_TRUE
(
a13
==
a10
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
1
);
}
void
caf_main
(
caf
::
actor_system
&
sys
)
{
caf
::
scoped_actor
self
{
sys
};
aout
(
self
)
<<
"Starting Test
\n
"
;
// test_calculateTime();
testActorRefList
(
sys
);
testOutputManager
(
sys
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment