Commit 498cead0 authored by David COME's avatar David COME
Browse files

Merged AutoReleaseBlock from anonymous namespaces

Now the all are into AutoReleaseBlock.hpp and the class has been templated to take into account the 2 types of MemoryManager
parent a1924fe4
* Payload.hpp
* This file is part of the Castor project.
* See
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* @author Castor Dev team,
#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
*(ie pushed back to the memory manager) in any case (exception or not)
template <class MemManagerT> class AutoReleaseBlock {
MemBlock *m_block;
MemManagerT& memManager;
AutoReleaseBlock(MemBlock* mb,MemManagerT& mm):
\ No newline at end of file
......@@ -29,27 +29,11 @@
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include "castor/tape/tapeserver/utils/suppressUnusedVariable.hpp"
#include "castor/tape/tapeserver/file/File.hpp"
#include "castor/tape/tapeserver/daemon/AutoReleaseBlock.hpp"
namespace {
unsigned long initAdler32Checksum() {
return adler32(0L,Z_NULL,0);
/*Use RAII to make sure the memory block is released
*(ie pushed back to the memory manager) in any case (exception or not)
class AutoReleaseBlock{
castor::tape::tapeserver::daemon::MemBlock *block;
castor::tape::tapeserver::daemon::MemoryManager& memManager;
AutoReleaseBlock(castor::tape::tapeserver::daemon::MemBlock* mb,
castor::tape::tapeserver::daemon::MemoryManager& mm):
namespace castor {
namespace tape {
......@@ -79,7 +63,7 @@ namespace daemon {
std::auto_ptr<castor::tape::tapeFile::WriteFile> output(openWriteFile(session,lc));
while(!m_fifo.finished()) {
MemBlock* const mb = m_fifo.popDataBlock();
AutoReleaseBlock releaser(mb,m_memManager);
AutoReleaseBlock<MemoryManager> releaser(mb,m_memManager);
if(/*m_migratingFile->fileid() != static_cast<unsigned int>(mb->m_fileid)
* || */blockId != mb->m_fileBlock || mb->m_failed ){
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