source: trunk/src/MSFillerWrapper.h @ 3046

Last change on this file since 3046 was 3046, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: Yes CAS-7764

Ready for Test: Yes

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description:


Release GIL in some time-consuming functions. Currently the following functions releases GIL:


  • MSFiller::fill
  • MSWriter::write
  • Scantable::applyBaselineTable
  • Scantable::subBaseline
  • CalibrationManager::calibrate
  • CalibrationManager::apply
File size: 1.7 KB
Line 
1//
2// C++ Interface: MSFillerWrapper
3//
4// Description:
5//
6// This class is wrapper class for MSFiller
7//
8// Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2010
9//
10// Copyright: See COPYING file that comes with this distribution
11//
12//
13#ifndef ASAPMSFILLER_WRAPPER_H
14#define ASAPMSFILLER_WRAPPER_H
15
16#include <casa/aips.h>
17#include <casa/Exceptions.h>
18#include <casa/Utilities/CountedPtr.h>
19#include <casa/Containers/Record.h>
20#include <casa/OS/File.h>
21
22#include <string>
23
24#include "ScantableWrapper.h"
25#include "MSFiller.h"
26#include "GILHandler.h"
27
28namespace asap
29{
30
31class MSFillerWrapper
32{
33public:
34  explicit MSFillerWrapper( ScantableWrapper tbl )
35    : filler_( 0 ),
36      attached_( false )
37  { stable_ = tbl.getCP() ; }
38
39  virtual ~MSFillerWrapper() { close() ; }
40
41  void open(const std::string& filename, const casa::Record& rec)
42  {
43    casa::File file( filename ) ;
44    if ( !file.exists() ) {
45      throw casa::AipsError( "File does not exist" ) ;
46    }
47    filler_ = new MSFiller( stable_ ) ;
48    if ( filler_->open( filename, rec ) ) {
49      attached_ = true ;
50      return ;
51    }
52    else {
53      throw casa::AipsError( "Failed to open file" ) ;
54    }
55  }
56
57  void close()
58  {
59    if ( attached_ ) {
60      filler_->close() ;
61    }
62  }
63
64  void fill()
65  {
66    GILHandler scopedRelease;
67
68    if ( attached_ ) {
69      filler_->fill() ;
70    }
71  }
72
73  // add dummy method for consistency
74  void setReferenceRegex(const std::string& rx) {
75    // do nothing
76  } 
77
78private:
79
80  MSFillerWrapper() ;
81  MSFillerWrapper(const MSFillerWrapper&) ;
82  MSFillerWrapper& operator=(const MSFillerWrapper&) ;
83
84  casa::CountedPtr<MSFiller> filler_ ;
85  bool attached_ ;
86  casa::CountedPtr<Scantable> stable_ ;
87};
88
89
90};
91#endif
Note: See TracBrowser for help on using the repository browser.