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
9f05b702
Commit
9f05b702
authored
2 years ago
by
KyleKlenk
Browse files
Options
Downloads
Patches
Plain Diff
Created new container class and tests for it
parent
a99f36d4
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
+70
-0
70 additions, 0 deletions
build/source/actors/OutputManager.h
build/source/testing/testing_main.cc
+67
-3
67 additions, 3 deletions
build/source/testing/testing_main.cc
with
137 additions
and
3 deletions
build/source/actors/OutputManager.h
0 → 100644
+
70
−
0
View file @
9f05b702
#ifndef OutputManager_H_
#define OutputManager_H_
#include
"caf/all.hpp"
#include
<vector>
class
ActorRefList
{
private:
int
currentSize
;
int
maxSize
;
std
::
vector
<
caf
::
actor
>
list
;
public:
// Constructor
ActorRefList
(
int
maxSize
){
this
->
currentSize
=
0
;
this
->
maxSize
=
maxSize
;
}
// Deconstructor
~
ActorRefList
(){};
int
getCurrentSize
()
{
return
this
->
currentSize
;
}
bool
isFull
()
{
return
list
.
size
()
==
this
->
maxSize
;
}
void
addActor
(
caf
::
actor
actor
)
{
if
(
this
->
isFull
())
{
throw
"List is full, cannot add actor to this list"
;
}
this
->
currentSize
++
;
list
.
push_back
(
actor
);
}
caf
::
actor
popActor
()
{
if
(
list
.
empty
())
{
throw
"List is empty, nothing to pop."
;
}
auto
actor
=
list
.
back
();
list
.
pop_back
();
this
->
currentSize
--
;
return
actor
;
}
};
class
OutputManager
{
private:
int
numVectors
;
std
::
vector
<
std
::
vector
<
caf
::
actor
>>
actorRefList
;
public:
// Constructor
OutputManager
(){}
// Deconstructor
~
OutputManager
(){};
};
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
build/source/testing/testing_main.cc
+
67
−
3
View file @
9f05b702
#include
"testCoordinator.h"
#include
"../actors/commonFunctions.h"
#include
"../actors/global.h"
#include
"../actors/OutputManager.h"
#include
<chrono>
#include
<iostream>
#include
<thread>
#define IS_TRUE(x) { if (!(x)) std::cout << __FUNCTION__ << " failed on line " << __LINE__ << std::endl; }
...
...
@@ -79,7 +81,6 @@ bool calcTimeAccumulate3Val(int sleepTime1, int sleepTime2, int sleepTime3) {
}
}
void
test_calculateTime
()
{
IS_TRUE
(
calcTimeTest
(
2
));
IS_TRUE
(
calcTimeTest
(
4
));
...
...
@@ -92,10 +93,73 @@ void test_calculateTime() {
IS_TRUE
(
calcTimeAccumulate3Val
(
5
,
2
,
3
));
}
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
om
=
new
ActorRefList
(
5
);
IS_TRUE
(
om
->
getCurrentSize
()
==
0
);
om
->
addActor
(
a1
);
IS_TRUE
(
om
->
getCurrentSize
()
==
1
);
om
->
addActor
(
a2
);
IS_TRUE
(
om
->
getCurrentSize
()
==
2
);
om
->
addActor
(
a3
);
IS_TRUE
(
om
->
getCurrentSize
()
==
3
);
om
->
addActor
(
a4
);
IS_TRUE
(
om
->
getCurrentSize
()
==
4
);
om
->
addActor
(
a5
);
IS_TRUE
(
om
->
getCurrentSize
()
==
5
);
try
{
om
->
addActor
(
a6
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
IS_TRUE
(
om
->
getCurrentSize
()
==
5
)
}
IS_TRUE
(
om
->
isFull
());
auto
a7
=
om
->
popActor
();
IS_TRUE
(
a7
==
a5
);
IS_TRUE
(
om
->
getCurrentSize
()
==
4
);
auto
a8
=
om
->
popActor
();
IS_TRUE
(
a8
==
a4
);
IS_TRUE
(
om
->
getCurrentSize
()
==
3
);
auto
a9
=
om
->
popActor
();
IS_TRUE
(
a9
==
a3
);
IS_TRUE
(
om
->
getCurrentSize
()
==
2
);
auto
a10
=
om
->
popActor
();
IS_TRUE
(
a10
==
a2
);
IS_TRUE
(
om
->
getCurrentSize
()
==
1
);
auto
a11
=
om
->
popActor
();
IS_TRUE
(
a11
==
a1
);
try
{
om
->
popActor
();
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
IS_TRUE
(
om
->
getCurrentSize
()
==
0
)
}
}
void
caf_main
(
caf
::
actor_system
&
sys
)
{
caf
::
scoped_actor
self
{
sys
};
aout
(
self
)
<<
"Starting Test
\n
"
;
test_calculateTime
();
// test_calculateTime();
testOutputManager
(
sys
);
}
CAF_MAIN
()
\ No newline at end of file
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