Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
b7b2264f
Commit
b7b2264f
authored
Nov 09, 2009
by
Sebastian Eichelbaum
Browse files
[STYLE]
parent
c8b233fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
15 deletions
+19
-15
src/kernel/WKernel.cpp
src/kernel/WKernel.cpp
+7
-5
src/kernel/WModuleContainer.cpp
src/kernel/WModuleContainer.cpp
+6
-3
src/kernel/WModuleContainer.h
src/kernel/WModuleContainer.h
+1
-1
src/kernel/WModuleFactory.cpp
src/kernel/WModuleFactory.cpp
+4
-6
src/kernel/WModuleFactory.h
src/kernel/WModuleFactory.h
+1
-0
No files found.
src/kernel/WKernel.cpp
View file @
b7b2264f
...
...
@@ -66,8 +66,8 @@ WKernel::WKernel( int argc, char* argv[], boost::shared_ptr< WGUI > gui )
// get module factory
m_moduleFactory
=
WModuleFactory
::
getModuleFactory
();
m_moduleContainer
=
boost
::
shared_ptr
<
WModuleContainer
>
(
new
WModuleContainer
(
"KernelRootContainer"
,
"Root module\
container in Kernel."
)
);
m_moduleContainer
=
boost
::
shared_ptr
<
WModuleContainer
>
(
new
WModuleContainer
(
"KernelRootContainer"
,
"Root module
container in Kernel."
)
);
// init GE, DataHandler, ...
init
();
...
...
@@ -129,7 +129,7 @@ char** WKernel::getArguments() const
void
WKernel
::
stop
()
{
getRootContainer
()
->
stop
();
getRootContainer
()
->
stop
();
}
int
WKernel
::
run
()
...
...
@@ -153,7 +153,8 @@ int WKernel::run()
// run module execution threads
// TODO(ebaum): after having modules loaded they should be started here.
// currently this is just the test module
/*WLogger::getLogger()->addLogMessage( "*** Starting modules:", "Kernel", LL_DEBUG );
/*
WLogger::getLogger()->addLogMessage( "*** Starting modules:", "Kernel", LL_DEBUG );
for( std::list< boost::shared_ptr< WModule > >::iterator list_iter = m_modules.begin(); list_iter != m_modules.end();
++list_iter )
{
...
...
@@ -183,7 +184,8 @@ int WKernel::run()
++list_iter )
{
( *list_iter )->wait( true );
}*/
}
*/
// TODO(schurade): this must be moved somewhere else, and realize the wait loop in another fashion
while
(
!
m_gui
->
isInitalized
()
)
...
...
src/kernel/WModuleContainer.cpp
View file @
b7b2264f
...
...
@@ -22,6 +22,7 @@
//
//---------------------------------------------------------------------------
#include <set>
#include <string>
#include <sstream>
...
...
@@ -73,7 +74,8 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module )
m_modules
.
insert
(
module
);
lock
.
unlock
();
module
->
setAssociatedContainer
(
shared_from_this
()
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Associated module "
+
module
->
getName
()
+
" with container."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_DEBUG
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Associated module "
+
module
->
getName
()
+
" with container."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_DEBUG
);
// now module->isUsable() is true
// -> so run it
...
...
@@ -106,13 +108,14 @@ void WModuleContainer::remove( boost::shared_ptr< WModule > module )
void
WModuleContainer
::
stop
()
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Stopping modules."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_DEBUG
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Stopping modules."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_DEBUG
);
// read lock
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_moduleSetLock
);
for
(
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>::
iterator
listIter
=
m_modules
.
begin
();
listIter
!=
m_modules
.
end
();
++
listIter
)
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Waiting for module "
+
(
*
listIter
)
->
getName
()
+
" to finish."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_DEBUG
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Waiting for module "
+
(
*
listIter
)
->
getName
()
+
" to finish."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_DEBUG
);
(
*
listIter
)
->
wait
(
true
);
}
slock
.
unlock
();
...
...
src/kernel/WModuleContainer.h
View file @
b7b2264f
...
...
@@ -111,7 +111,7 @@ protected:
* Description of the module.
*/
std
::
string
m_description
;
private:
};
...
...
src/kernel/WModuleFactory.cpp
View file @
b7b2264f
...
...
@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <set>
#include <string>
#include "../common/WLogger.h"
...
...
@@ -57,12 +58,9 @@ void WModuleFactory::load()
{
// load modules
WLogger
::
getLogger
()
->
addLogMessage
(
"Loading Modules"
,
"ModuleFactory"
,
LL_INFO
);
std
::
cout
<<
"sdasdshallo"
<<
std
::
endl
;
// operation must be exclusive
std
::
cout
<<
"sdasdshallo"
<<
std
::
endl
;
boost
::
unique_lock
<
boost
::
shared_mutex
>
lock
=
boost
::
unique_lock
<
boost
::
shared_mutex
>
(
m_prototypesLock
);
std
::
cout
<<
"sdasdshallo"
<<
std
::
endl
;
// currently the prototypes are added by hand. This will be done automatically later.
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMNavSlices
()
)
);
...
...
@@ -84,7 +82,7 @@ void WModuleFactory::load()
++
listIter
)
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Loading module: "
+
(
*
listIter
)
->
getName
(),
"ModuleFactory"
,
LL_DEBUG
);
// that should not happen. Names should not occur multiple times since they are unique
if
(
names
.
count
(
(
*
listIter
)
->
getName
()
)
)
{
...
...
@@ -134,7 +132,7 @@ const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByName( std::stri
// for this a read lock is sufficient
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_prototypesLock
);
// find first and only prototype (ensured during load()
)
// find first and only prototype (ensured during load()
)
boost
::
shared_ptr
<
WModule
>
ret
=
boost
::
shared_ptr
<
WModule
>
();
for
(
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>::
iterator
listIter
=
m_prototypes
.
begin
();
listIter
!=
m_prototypes
.
end
();
++
listIter
)
...
...
@@ -146,7 +144,7 @@ const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByName( std::stri
}
}
slock
.
unlock
();
slock
.
unlock
();
// if not found -> throw
if
(
ret
==
boost
::
shared_ptr
<
WModule
>
()
)
...
...
src/kernel/WModuleFactory.h
View file @
b7b2264f
...
...
@@ -26,6 +26,7 @@
#define WMODULEFACTORY_H
#include <set>
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
...
...
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