Example #1
0
static PyObject *
pyorbit_object_adaptor_set_thread_hint (PyCORBA_Object *self, PyObject *args)
{
    ORBitThreadHint hint;

    if (!PyArg_ParseTuple(args, "i:ObjectAdaptor.set_thread_hint", &hint))
	return NULL;
    ORBit_ObjectAdaptor_set_thread_hint((ORBit_ObjectAdaptor)self->objref, hint);
    Py_INCREF(Py_None);
    return Py_None;
}
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;
}