/*
 *  ZThreads, a platform-independant, multithreading and 
 *  synchroniation library
 *
 *  Copyright (C) 2001 Eric Crahen, See LGPL.TXT for details
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 *  SUNY @ Buffalo, hereby disclaims all copyright interest in the
 *  ZThreads library written by Eric Crahen
 */

#include "zthread/SynchronizationExceptions.h"

using namespace ZThread;
using namespace std;


Synchronization_Exception::Synchronization_Exception() throw()
  : _msg( new string("Synchronization exception") ), _count(new int(1)) { 

}

Synchronization_Exception::Synchronization_Exception(const char* msg) throw()
  : _msg( new string(msg) ), _count(new int(1)) {
  
}

Synchronization_Exception::Synchronization_Exception(const Synchronization_Exception& e) throw()
  : _msg(e._msg), _count(e._count) {

  (*_count)++;

}

Synchronization_Exception::~Synchronization_Exception() throw() {

  try {

    if(--(*_count) < 1) {
      delete _msg;
      delete _count;
    }

  } catch(...) {  }

}

const char *Synchronization_Exception::what() const throw() {
    return _msg->c_str();
}


Interrupted_Exception::Interrupted_Exception(const char* msg) throw() 
  : Synchronization_Exception(msg) {
}

Interrupted_Exception::Interrupted_Exception() throw() 
  : Synchronization_Exception("Operation interrupted") {
}


Unexpected_Exception::Unexpected_Exception(const char* msg) throw() 
  : Synchronization_Exception(msg) {
}

Unexpected_Exception::Unexpected_Exception() throw() 
  : Synchronization_Exception("Unexpected exception") {
}


Deadlock_Exception::Deadlock_Exception(const char* msg) throw()
  : Synchronization_Exception(msg) {
}

Deadlock_Exception::Deadlock_Exception() throw()
  : Synchronization_Exception("Deadlock detected") {
}


InvalidOp_Exception::InvalidOp_Exception(const char* msg) throw() 
  : Synchronization_Exception(msg) {
  
}


InvalidOp_Exception::InvalidOp_Exception() throw() 
  : Synchronization_Exception("Invalid operation attempted") {
  
}

Initialization_Exception::Initialization_Exception(const char* msg) throw() 
  : Synchronization_Exception(msg) {

}

Initialization_Exception::Initialization_Exception() throw() 
  : Synchronization_Exception("Initialization error, could not allocate resource") {

}


Cancelation_Exception::Cancelation_Exception() throw()
  : Synchronization_Exception("Object canceled") {
  
}

Cancelation_Exception::Cancelation_Exception(const char* msg) throw()
  : Synchronization_Exception(msg) {
  
}


Timeout_Exception::Timeout_Exception() throw() 
  : Synchronization_Exception("") {

}



