Commit e92123ba authored by David COME's avatar David COME
Browse files

Added a bunch of comments into AutoReleaseBlock and tapeserver/exception/Exception.hpp

parent ca609e29
......@@ -25,21 +25,42 @@
#pragma once
#include <memory>
#include "castor/tape/tapeserver/daemon/MemBlock.hpp"
namespace castor {
namespace tape {
namespace tapeserver {
namespace daemon {
/*Use RAII to make sure the memory block is released
/*
* Use RAII to make sure the memory block is released
*(ie pushed back to the memory manager) in any case (exception or not)
* Example of use
* {
* MemBlock* block = getItFromSomewhere()
* {Recall/Migration}MemoryManager mm;
* AutoReleaseBlock releaser(block,mm);
* }
*/
template <class MemManagerT> class AutoReleaseBlock {
MemBlock *m_block;
/**
* The block to release
*/
MemBlock* const m_block;
/**
* To whom it should be given back
*/
MemManagerT& memManager;
public:
AutoReleaseBlock(MemBlock* mb,MemManagerT& mm):
/**
*
* @param mb he block to release
* @param mm To whom it should be given back
*/
AutoReleaseBlock(MemBlock* const mb,MemManagerT& mm):
m_block(mb),memManager(mm){}
//let the magic begin
~AutoReleaseBlock(){
memManager.releaseBlock(m_block);
}
......
......@@ -53,8 +53,9 @@ namespace tape {
EndOfFile(const std::string & w): castor::exception::Exception(w) {}
virtual ~EndOfFile() throw() {}
};
/**
* Used
* Used to signal an error has happened during the migration process
*/
class ErrorFlag : public castor::exception::Exception {
public:
......@@ -62,7 +63,9 @@ namespace tape {
virtual ~ErrorFlag() throw() {}
};
/**
* A generic exception thrown when there is something wrong with the memory
*/
class MemException: public castor::tape::Exception {
public:
MemException(const std::string & what): Exception(what) {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment