1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "ThreadPT.hxx"
20 #include "Exception.hxx"
23 using namespace YACS::BASES;
25 ThreadPT::ThreadPT(ThreadJob funcPtr, void *stack)
28 void **stackT=(void **) stack;
29 err=pthread_create(&_threadId,0,funcPtr,stackT);
30 if(err!=0)throw Exception("Error in thread creation");
33 bool ThreadPT::operator==(const ThreadPT& other)
35 return pthread_equal(_threadId, other._threadId) != 0;
38 //! Detach thread to release resources on exit
39 void ThreadPT::detach()
41 pthread_detach(pthread_self());
44 void ThreadPT::exit(void *what)
52 pthread_join(_threadId, &ret);
55 void ThreadPT::sleep(unsigned long usec)