Changeset 3391 in Sophya for trunk/SophyaExt


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

Adaptation a ThSafeOp (thread-safety) pour BaseDataTable, Reza 22/11/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/swfitsdtable.cc

    r3069 r3391  
    11#include "swfitsdtable.h"
    22#include "fitshdtable.h"
    3 #include "sopnamsp.h"
    43#include "pexceptions.h"
    5 
     4#include "thsafeop.h"
     5
     6namespace SOPHYA {
    67
    78/*!
    8    \class SOPHYA::SwFitsDataTable
     9   \class SwFitsDataTable
    910   \ingroup FitsIOServer
    1011   This class can be used to organize data in table (row-column) form.
     
    101102}
    102103
    103 //! copy constructor - shares the data
     104//! copy constructor - shares the data (and copies the thread safety state)
    104105SwFitsDataTable::SwFitsDataTable(SwFitsDataTable const & a)
    105106  : BaseDataTable(a.SegmentSize()),
     
    130131  // On copie la structure de table
    131132  CopyStructure(a);
     133  if (a.IsThreadSafe())  SetThreadSafe(true);
     134  else SetThreadSafe(false);
    132135
    133136  //
     
    223226  if (mInfo) delete mInfo;
    224227  mInfo = NULL;
     228  if (mThS) delete mThS;
     229  mThS = NULL;
     230
    225231  mMin.clear();
    226232  mMax.clear();
     
    403409sa_size_t SwFitsDataTable::AddRow(const r_8* data)
    404410{
     411  if (mThS) mThS->lock();   // tread-safety
    405412  if (NRows() == 0) {  // On cree la definition de la table FITS au premier appel
    406413    FitsHandler<BaseDataTable> fio(*this);
     
    415422    mMinMaxNEnt[k]++;
    416423  }
     424  if (mThS) mThS->unlock(); // tread-safety
    417425  return BaseDataTable::AddRow(data);
    418426}
     
    426434sa_size_t SwFitsDataTable::AddRow(const MuTyV * data)
    427435{
     436  if (mThS) mThS->lock();   // tread-safety
    428437  if (NRows() == 0) {  // On cree la definition de la table FITS au premier appel
    429438    FitsHandler<BaseDataTable> fio(*this);
     
    438447    mMinMaxNEnt[k]++;
    439448  }
     449  if (mThS) mThS->unlock();   // tread-safety
    440450  return BaseDataTable::AddRow(data);
    441451}
     
    453463  return AddRow(data.MTVPtr());
    454464}
     465
     466} // FIN namespace SOPHYA
Note: See TracChangeset for help on using the changeset viewer.