add complete locking to the ProcDispatcher
on both levels - the front-end needs locking to ensure consistent state (memory barrier) - the back-end nees locking to coordinate command processing
This commit is contained in:
parent
4c30c349aa
commit
a853851447
3 changed files with 39 additions and 4 deletions
|
|
@ -35,12 +35,15 @@
|
|||
//using boost::str;
|
||||
|
||||
using backend::ThreadJoinable;
|
||||
using lib::Sync;
|
||||
using lib::RecursiveLock_Waitable;
|
||||
|
||||
namespace proc {
|
||||
namespace control {
|
||||
|
||||
class DispatcherLoop
|
||||
: ThreadJoinable
|
||||
, public Sync<RecursiveLock_Waitable>
|
||||
{
|
||||
public:
|
||||
DispatcherLoop (Subsys::SigTerm notification)
|
||||
|
|
@ -93,6 +96,7 @@ namespace control {
|
|||
bool
|
||||
ProcDispatcher::start (Subsys::SigTerm termNotification)
|
||||
{
|
||||
Lock sync(this);
|
||||
if (runningLoop_) return false;
|
||||
|
||||
runningLoop_.reset (
|
||||
|
|
@ -111,6 +115,7 @@ namespace control {
|
|||
bool
|
||||
ProcDispatcher::isRunning()
|
||||
{
|
||||
Lock sync(this);
|
||||
return bool(runningLoop_);
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +124,7 @@ namespace control {
|
|||
void
|
||||
ProcDispatcher::requestStop()
|
||||
{
|
||||
Lock sync(this);
|
||||
UNIMPLEMENTED ("trigger shutdown into the dispacher loop thread");
|
||||
}
|
||||
|
||||
|
|
@ -127,6 +133,7 @@ namespace control {
|
|||
void
|
||||
ProcDispatcher::activate()
|
||||
{
|
||||
Lock sync(this);
|
||||
INFO (command, "Session command processing activated."); ///////////////TODO only emit these log messages when processing is *really* started/stopped
|
||||
TODO ("implement command processing queue");
|
||||
}
|
||||
|
|
@ -135,6 +142,7 @@ namespace control {
|
|||
void
|
||||
ProcDispatcher::deactivate()
|
||||
{
|
||||
Lock sync(this);
|
||||
INFO (command, "Session command interface closed.");
|
||||
TODO ("implement command processing queue");
|
||||
}
|
||||
|
|
@ -143,6 +151,7 @@ namespace control {
|
|||
void
|
||||
ProcDispatcher::clear()
|
||||
{
|
||||
Lock sync(this);
|
||||
if (!empty())
|
||||
WARN (command, "DISCARDING pending Session commands.");
|
||||
TODO ("implement command processing queue");
|
||||
|
|
@ -152,6 +161,7 @@ namespace control {
|
|||
bool
|
||||
ProcDispatcher::empty() const
|
||||
{
|
||||
Lock sync(this);
|
||||
TODO ("implement command processing queue");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
//#include "lib/symbol.hpp"
|
||||
#include "common/subsys.hpp"
|
||||
#include "lib/depend.hpp"
|
||||
#include "lib/sync.hpp"
|
||||
|
||||
#include <memory>
|
||||
//#include <functional>
|
||||
|
|
@ -60,6 +61,7 @@ namespace control {
|
|||
* @todo Type-comment
|
||||
*/
|
||||
class ProcDispatcher
|
||||
: public lib::Sync<>
|
||||
{
|
||||
unique_ptr<DispatcherLoop> runningLoop_;
|
||||
|
||||
|
|
|
|||
|
|
@ -224,11 +224,34 @@
|
|||
<node CREATED="1481599413419" ID="ID_673133356" MODIFIED="1481599420290" TEXT="Ticket #318"/>
|
||||
<node CREATED="1481599421021" ID="ID_461768132" MODIFIED="1481599492544" TEXT="Locking klären">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481599447034" ID="ID_27053080" MODIFIED="1481599486152" TEXT="muß unique_ptr locken">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1481684383530" ID="ID_236117" MODIFIED="1481684451657" TEXT="zwei unabhängige Locks">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1481684391921" ID="ID_138369898" MODIFIED="1481684442846" TEXT="Front-End">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
das Lock sorgt hier für konsistenten Zustand und Sichtbarkeit (memory barrier)
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node CREATED="1481684394544" ID="ID_1314197501" MODIFIED="1481684422640" TEXT="Back-End">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Lock ist hier das Dispatcher-Lock
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481599454593" ID="ID_1547594303" MODIFIED="1481599484757" TEXT="muß Operationen auf dem Thread locken">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node CREATED="1481599468712" ID="ID_1273965744" MODIFIED="1481599482440" TEXT="Vorsicht beim Anhalten (Deadlock-Gefahr)">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue