You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to grpc.io
If I want to implement an asynchronous server, is it safe to pass StreamObserver received with the request to another thread and call onNext and onCompleted on it?
Is that the right way to go anyway?
Eric Anderson
unread,
Sep 28, 2015, 12:01:36 PM9/28/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
If I want to implement an asynchronous server, is it safe to pass StreamObserver received with the request to another thread and call onNext and onCompleted on it?
Yes, it is safe to pass StreamObserver to another thread. Note that the object is not thread-safe, so if you may call methods on it from multiple threads simultaneously you should do your own locking/synchronization. But if you are just passing it to another thread and the current thread doesn't call methods on it past that point, everything should "just work."
Is that the right way to go anyway?
Yes, for fully-asynchronous processing we would expect you to start any I/O on the current thread and then call methods on StreamObserver from some other thread once the I/O completes.