123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- // SNF4CGP/ScannerPool.cpp
- // Copyright (C) 2009 ARM Research Labs, LLC.
- // See www.armresearch.com for more information.
-
- #include "ScannerPool.hpp"
-
- #include "../SNFMulti/SNFMulti.hpp"
- #include "../CodeDweller/threading.hpp"
- #include "../CodeDweller/faults.hpp"
-
- using namespace std;
-
- //// Scanner ///////////////////////////////////////////////////////////////////
-
- Scanner::Scanner(snf_RulebaseHandler& Rulebase) : // When constructed allocates an engine.
- Rulebase_(Rulebase), // At it's core is a Rulebase handle.
- Engine_(new snf_EngineHandler()) { // It contains it's own scan engine.
- Engine_->open(&Rulebase); // The scan engine is initialized.
- }
-
- Scanner::~Scanner() { // When destructed destroys the engine.
- try { // Destructors don't throw.
- if(Engine_) { // Safely destroy the engine.
- Engine_->close();
- Engine_=0;
- }
- }
- catch(...) {}
- }
-
- snf_RulebaseHandler& Scanner::Rulebase() { // Provide access to the Rulebase
- return Rulebase_;
- }
-
- RuntimeCheck CheckScannerEngineIsValid("Scanner::Engine() Check(0 != Engine_)");
-
- snf_EngineHandler& Scanner::Engine() { // Provide access to the Engine.
- CheckScannerEngineIsValid(0 != Engine_);
- return (*Engine_);
- }
-
- //// ScannerPool ///////////////////////////////////////////////////////////////
-
- ScannerPool::ScannerPool() : // Constructed simply.
- Rulebase_(0),
- ScannerCount(0) {
- }
-
- ScannerPool::~ScannerPool() { // Cleanup on the way out.
- try { stop(); }
- catch(...) {}
- }
-
- void ScannerPool::init(string Configuration) { // Get ready to provide scanners.
- }
-
- void ScannerPool::stop() { // Shutdown and clean up.
- }
-
- Scanner* ScannerPool::makeScanner() { // Create and count a scanner.
- }
-
- Scanner& ScannerPool::grab() { // Provides a Scanner from the pool.
- }
-
- void ScannerPool::killScannerFromPool() { // Destroy and count a pooled scanner.
- }
-
- void ScannerPool::drop(Scanner& S) { // Returns a Scanner to the pool.
- }
-
- //// ScopeScanner //////////////////////////////////////////////////////////////
-
- ScopeScanner::ScopeScanner(ScannerPool& P) : // Constructed with the pool.
- ScannerPool_(P),
- Scanner_(P.grab()) { // Grabs a Scanner on the way up.
- }
-
- ScopeScanner::~ScopeScanner() { // When destroyed drops the scanner.
- try { ScannerPool_.drop(Scanner_); }
- catch(...) {}
- }
-
- snf_RulebaseHandler& ScopeScanner::Rulebase() { // Provides access to the Rulebase.
- return Scanner_.Rulebase();
- }
-
- snf_EngineHandler& ScopeScanner::Engine() { // Provides access to a scan engine.
- return Scanner_.Engine();
- }
|