ICE 3.4.2
[php5-ice-freebsdport.git] / py / modules / IcePy / ThreadNotification.cpp
blob7d3c1af06b21c4509bb96c27d7b8288f6fd8ffbc
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 #ifdef _WIN32
11 # include <IceUtil/Config.h>
12 #endif
13 #include <ThreadNotification.h>
15 using namespace std;
16 using namespace IcePy;
18 IcePy::ThreadNotificationWrapper::ThreadNotificationWrapper(PyObject* threadNotification) :
19 _threadNotification(threadNotification)
21 Py_INCREF(threadNotification);
24 void
25 IcePy::ThreadNotificationWrapper::start()
27 AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
29 PyObjectHandle tmp = PyObject_CallMethod(_threadNotification.get(), STRCAST("start"), 0);
30 if(!tmp.get())
32 throwPythonException();
36 void
37 IcePy::ThreadNotificationWrapper::stop()
39 AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
41 PyObjectHandle tmp = PyObject_CallMethod(_threadNotification.get(), STRCAST("stop"), 0);
42 if(!tmp.get())
44 throwPythonException();
48 PyObject*
49 IcePy::ThreadNotificationWrapper::getObject()
51 return _threadNotification.get();