Hi Ettore, On Wed, 2002-05-15 at 18:48, Ettore Perazzoli wrote: > BTW, if we want to add extensions to work around the lack of decent > support for threaded apps, something that would be really useful is a > general mechanism for doing async calls.
Ok; this is in ORBit2/include/orbit/orb-core/orbit-small.h As I say, currently there is no IDL compiler support for this, so you need to be slightly clueful to produce your own pseudo-stubs. I understand there is a specified binding for async stuff in the latest CORBA release, I havn't looked at it yet, hopefully we can support it trivially. Either way for this you have: typedef void (*ORBitAsyncInvokeFunc) (CORBA_Object object, ORBit_IMethod *m_data, ORBitAsyncQueueEntry *aqe, gpointer user_data, CORBA_Environment *ev); /* Various bits for Async work */ void ORBit_small_invoke_async (CORBA_Object obj, ORBit_IMethod *m_data, ORBitAsyncInvokeFunc fn, gpointer user_data, gpointer *args, CORBA_Context ctx, CORBA_Environment *ev); void ORBit_small_demarshal_async (ORBitAsyncQueueEntry *aqe, gpointer ret, gpointer *args, CORBA_Environment *ev); The ORBit_IMethod is the method / argument description, containing all the types etc. neccessary to marshal the stuff. The invoke_async is much like the existing invoke method; here's a use of it: Unknown resolve (in ResolveOptions options, in string requestedInterface); invocation: resolve_async_ctx_t *ctx; /* this argument indirection is what all the stubs / skels * already use, documented in * ORBit2/doc/internals/interface-indirection.gnumeric */ gpointer args [] = { &options, &interface_name }; ctx = g_new0 (resolve_async_ctx_t, 1); ... if (!resolve_method) setup_methods (); /* This sets up resolve_method to point to the the right IMethod method description */ ORBit_small_invoke_async ( ctx->moniker, resolve_method, resolve_async_cb, ctx, args, NULL, ev); resolve_async_cb: static void resolve_async_cb (CORBA_Object object, ORBit_IMethod *m_data, ORBitAsyncQueueEntry *aqe, gpointer user_data, CORBA_Environment *ev) { resolve_async_ctx_t *ctx = user_data; if (BONOBO_EX (ev)) /* the resolve failed for some reason */ ; else { Bonobo_Unknown object; /* no out arguments, 'Unknown' return type */ ORBit_small_demarshal_async (aqe, &object, NULL, ev); if (BONOBO_EX (ev)) object = CORBA_OBJECT_NIL; /* chain on to some other user callback ? */ } g_free (ctx); } As I say, hopefully we can do most of that automatically in future. > Right now it's a mess of > oneway void doSomethingAsynchronously (in Bonobo::Listener result_listener); Yes. > Problems with this are: > > * You have to set up the listener yourself, connect the > callback, kill the listener. Annoying and somewhat > error-prone. And inefficient. > * There is no way to document what type the listener expects, so > you can easily mess up the types. :-) that sucks. > * You have to use CORBA::anys (yuck). > * All in all, it's pretty damn ugly. ;-) Yes. > Instead, it would be nice to just normally say: > > SomeResultType doSomethingAsynchronously (); > > and have ORBit provide me with a parameter to specify the callback for > the result when I invoke the function, i.e. > > Blah_doSomethingAsynchronously_async (objref, callback, &ev); Yes; as I say we don't auto-generate that yet, but the guts are there. I must say I quite like Miguel's .Net approach of having two methods, so you can choose to block for the return value if it hasn't arrived yet [ and of course the fully async callback approach is important too ]. I hope that gives you some hope :-) Regards, Michael. -- [EMAIL PROTECTED] <><, Pseudo Engineer, itinerant idiot _______________________________________________ evolution-hackers maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/evolution-hackers