This is how I handle the same issue.  This would be similar to most 
multi-threaded daemons taking client input.  The manager reads the message 
type and passes the socket/stream to a handling thread.

On Monday, July 8, 2013 10:59:12 AM UTC-7, Ilia Mirkin wrote:
>
> Unfortunately it's not guaranteed that earlier fields appear earlier 
> in the message. Although that is often the case, I wouldn't recommend 
> writing your code s.t. it assumes this. The usual way that I handle 
> this is by splitting the message into a header and data message, and 
> then send something like 
>
> <header length varint> 
> <header data> 
> <data length varint> 
> <data data> 
>
> That way your manager thread just decodes the header figures out what 
> to do, and sends it on. Then the actual worker thread decodes the 
> data. 
>
> If this is not an option, you can write a custom decoder that just 
> skips over fields you don't need to read. This is a little tricky, but 
> if you're not trying to be too generic it shouldn't be that much code. 
>
>
> On Mon, Jul 8, 2013 at 6:54 AM,  <[email protected] <javascript:>> wrote: 
> > Hi Group, 
> > I am using protobuf in a multi-threaded software. Here manager thread 
> > decodes the protobuf encoded message and then assign the message to a 
> > particular worker thread based on key. I want to minimize per message 
> > processing at manager thread. Is it possible to encode the key at the 
> head 
> > of message and decode only this key at manager thread. Complete decoding 
> of 
> > message will be moved to the actual worker thread. 
> > thanks 
> > Ittium 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Protocol Buffers" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/protobuf. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to