On Thu, Jan 08, 2009 at 10:00:35AM -0800, Alan Kligman wrote:
> That's one way to do it. You can do one better( without threading,
> that is ) like this, though:
It's not better but 'looks more simple'. From threading only Condition is
used which is very cheap compared to network interaction. Your code only
works for synchronous cases. My first variants looks like Yours.
 
> def call( method, request ):
>     class callbackClass( object ):
>         def __init__( self ):
>             self.response = None
>         def __call__( self, response ):
>             self.response = response
>     controller = Controller()
>     callback = callbackClass()
>     method( controller, request, callback )
>     return callback.response
> 
> In this case, we're only using one thread and hiding the control flow
> inside a class that behaves like a function, where we can retrieve the
> return value later and actually return it.
So You must every time check that channel implementation is synchronous.
And code became unportable to async channels.
                Pavel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to