Ignore:
Timestamp:
Nov 22, 2007, 7:25:40 PM (18 years ago)
Author:
ansari
Message:

Implementation NTuple::Fill(), BaseDataTable:;AddRow()/GetRow() thread-safe - Reza 22/11/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/HiStats/swppfdtable.cc

    r3031 r3392  
    11#include "swppfdtable.h"
    2 #include "sopnamsp.h"
    32#include "pexceptions.h"
    4 
     3#include "thsafeop.h"
     4
     5namespace SOPHYA {
    56
    67/*!
    7    \class SOPHYA::SwPPFDataTable
     8   \class SwPPFDataTable
    89   \ingroup HiStats
    910   This class can be used to organize data in table (row-column) form.
     
    9697}
    9798
    98 //! copy constructor - shares the data
     99//! copy constructor - shares the data (and copies the thread safety state)
     100
    99101SwPPFDataTable::SwPPFDataTable(SwPPFDataTable const & a)
    100102  : BaseDataTable(a.SegmentSize()),
     
    137139  // On copie la structure de table
    138140  CopyStructure(a);
     141  if (a.IsThreadSafe())  SetThreadSafe(true);
     142  else SetThreadSafe(false);
    139143
    140144  //
     
    229233  if (mInfo) delete mInfo;
    230234  mInfo = NULL;
     235  if (mThS) delete mThS;
     236  mThS = NULL;
    231237  mMin.clear();
    232238  mMax.clear();
     
    355361  // On est oblige de calculer les min-max lors du remplissage
    356362  // On ne peut pas en effet 'relire' le swap pendant l'ecriture
     363  if (mThS) mThS->lock();   // tread-safety
    357364  for(sa_size_t k=0; k<NVar(); k++) {
    358365    double x = data[k];
     
    361368    mMinMaxNEnt[k]++;
    362369  }
     370  if (mThS) mThS->unlock(); // tread-safety
    363371  return BaseDataTable::AddRow(data);
    364372}
     
    373381  // On est oblige de calculer les min-max lors du remplissage
    374382  // On ne peut pas en effet 'relire' le swap pendant l'ecriture
     383  if (mThS) mThS->lock();   // tread-safety
    375384  for(sa_size_t k=0; k<NVar(); k++) {
    376385    double x = (double)data[k];
     
    379388    mMinMaxNEnt[k]++;
    380389  }
     390  if (mThS) mThS->unlock(); // tread-safety
    381391  return BaseDataTable::AddRow(data);
    382392}
     
    394404  return AddRow(data.MTVPtr());
    395405}
     406
     407} // FIN namespace SOPHYA
Note: See TracChangeset for help on using the changeset viewer.