From: Christian P. <cp...@us...> - 2005-01-24 01:33:09
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11354/src Added Files: AtomicInt.win32.cpp Log Message: Added win32 implementation of AtomicInt --- NEW FILE: AtomicInt.win32.cpp --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@fr... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library 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 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library 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. * ***************************************************************************/ #include "pclasses/AtomicTraits.h" #include <windows.h> namespace P { namespace Traits { void AtomicTraits<int>::set(int* atomic, int val) throw() { *atomic = val; } int AtomicTraits<int>::get(const int* val) throw() { return *val; } void AtomicTraits<int>::inc(int* val) throw() { InterlockedIncrement((volatile LONG*)val); } bool AtomicTraits<int>::incAndTest(int* val) throw() { return InterlockedIncrement((volatile LONG*)val) == 0 ? true : false; } void AtomicTraits<int>::dec(int* val) throw() { InterlockedDecrement((volatile LONG*)val); } bool AtomicTraits<int>::decAndTest(int* val) throw() { return InterlockedDecrement((volatile LONG*)val) == 0 ? true : false; } } // !namespace Traits } // !namespace P |