PortableServer_POA server_create_multi_threaded_poa (CORBA_ORB orb, PortableServer_POA poa, PortableServer_POAManager poa_mgr, CORBA_Environment *ev) { const static MAX_POLICIES = 1; PortableServer_POA child_poa = CORBA_OBJECT_NIL; CORBA_PolicyList *poa_policies; poa_policies = CORBA_PolicyList__alloc (); poa_policies->_maximum = MAX_POLICIES; poa_policies->_length = MAX_POLICIES; poa_policies->_buffer = CORBA_PolicyList_allocbuf (MAX_POLICIES); CORBA_sequence_set_release (poa_policies, CORBA_TRUE); poa_policies->_buffer[0] = (CORBA_Policy) PortableServer_POA_create_thread_policy ( poa, PortableServer_ORB_CTRL_MODEL, ev); child_poa = PortableServer_POA_create_POA (poa, "Thread Per Request POA", poa_mgr, poa_policies, ev); if (etk_raised_exception(ev)) goto failed_create_poa; ORBit_ObjectAdaptor_set_thread_hint ((ORBit_ObjectAdaptor) child_poa, ORBIT_THREAD_HINT_PER_REQUEST); CORBA_Policy_destroy (poa_policies->_buffer[0], ev); if (etk_raised_exception(ev)) goto failed; CORBA_free (poa_policies); return child_poa; failed_create_poa: /* FIXME, in case of error, ev is set, but destructor should not * return except anyway */ CORBA_Policy_destroy (poa_policies->_buffer[0], ev); CORBA_free (poa_policies); failed: return CORBA_OBJECT_NIL; }
static PyObject * pyorbit_poa_create_thread_policy(PyCORBA_Object *self, PyObject *args) { CORBA_Environment ev; PyObject *py_policy; PortableServer_ThreadPolicyValue value; PortableServer_ThreadPolicy policy; if (!PyArg_ParseTuple(args, "i:POA.create_thread_policy", &value)) return NULL; CORBA_exception_init(&ev); policy = PortableServer_POA_create_thread_policy((PortableServer_POA)self->objref, value, &ev); if (pyorbit_check_ex(&ev)) return NULL; py_policy = pycorba_policy_new((CORBA_Object) policy); CORBA_Object_release((CORBA_Object) policy, &ev); return py_policy; }