Changeset 10919 for trunk/FACT++


Ignore:
Timestamp:
06/07/11 22:14:11 (13 years ago)
Author:
tbretz
Message:
Added local mutices to protect Write calls from different threads - the current implementation is even overprotective
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/MessageDim.cc

    r10570 r10919  
    11#include "MessageDim.h"
     2
     3#include <mutex>
    24
    35#include "tools.h"
     
    6668int MessageDimTX::Write(const Time &t, const string &txt, int qos)
    6769{
     70    static mutex mtx;
     71
     72    mtx.lock();
     73
    6874    MessageImp::Write(t, txt, qos);
    6975
     
    7783        Out() << " !! " << t.GetAsStr() << " - Sending failed!" << endl;
    7884
     85    mtx.unlock();
     86
    7987    return rc;
    8088}
    81 
    82 
    8389
    8490// **************************************************************************
  • trunk/FACT++/src/MessageImp.cc

    r10508 r10919  
    1313
    1414#include <stdarg.h>
     15
     16#include <mutex>
    1517
    1618#include "tools.h"
     
    105107int MessageImp::Write(const Time &time, const string &txt, int severity)
    106108{
     109    static mutex mtx;
     110
     111    mtx.lock();
     112
    107113    switch (severity)
    108114    {
     
    116122    }
    117123    fOut << time.GetAsStr() << " - " << txt << endl;
     124
     125    mtx.unlock();
    118126
    119127    return 0;
Note: See TracChangeset for help on using the changeset viewer.