{"action":"created","issue":{"url":"https://api.github.com/repos/google/flatbuffers/issues/4306","repository_url":"https://api.github.com/repos/google/flatbuffers","labels_url":"https://api.github.com/repos/google/flatbuffers/issues/4306/labels{/name}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/4306/comments","events_url":"https://api.github.com/repos/google/flatbuffers/issues/4306/events","html_url":"https://github.com/google/flatbuffers/issues/4306","id":228061040,"number":4306,"title":"gRPC Buffers","user":{"login":"llchan","id":51099,"avatar_url":"https://avatars1.githubusercontent.com/u/51099?v=3","gravatar_id":"","url":"https://api.github.com/users/llchan","html_url":"https://github.com/llchan","followers_url":"https://api.github.com/users/llchan/followers","following_url":"https://api.github.com/users/llchan/following{/other_user}","gists_url":"https://api.github.com/users/llchan/gists{/gist_id}","starred_url":"https://api.github.com/users/llchan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llchan/subscriptions","organizations_url":"https://api.github.com/users/llchan/orgs","repos_url":"https://api.github.com/users/llchan/repos","events_url":"https://api.github.com/users/llchan/events{/privacy}","received_events_url":"https://api.github.com/users/llchan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-05-11T17:09:49Z","updated_at":"2017-06-07T21:47:04Z","closed_at":"2017-06-07T21:47:04Z","body":"I am experimenting with the flatbuffers + grpc integration, and had some thoughts/questions on the buffer refs:\r\n- As it stands right now, when I write the `BufferRef` back from an rpc call, it's referencing a piece of memory I own. However, it's not immediately obvious to me how to get a callback/notification that the copy into the grpc buffer is finished and it is safe to reuse/free/realloc the buffer. Is there an existing way to do this safely? Is it doable via a completion queue? I'm using the synchronous C++ grpc api.\r\n- I think we can come up with a better flatbuffers grpc interface that manages buffer lifetimes automatically. gRPC has `grpc_slice` (a reference counted buffer for those who aren't familiar). Perhaps we could use a gRPC-specific flatbuffers allocator that allocates `grpc_slice` objects under the hood, so that we can transfer ownership to gRPC without copying or worrying about validity?\r\n- In addition to making memory ownership safer, using `grpc_slice` buffers would eliminate the extra copy into a grpc buffer (there's already a comment in the code with a TODO for this). This is even more important if the same response is broadcast to many clients. The current implementation would make a copy per client, but a `grpc_slice`/reference count based implementation could share the same response buffer. \r\n\r\nI'm happy to work on this and send a proposal in a PR, but please let me know if there's any feedback in case I'm missing something.\r\n\r\nBtw, I checked and it looks like the `grpc_slice` objects have mutexes and atomics, so I think they are thread safe (whew, one less thing to worry about)."},"comment":{"url":"https://api.github.com/repos/google/flatbuffers/issues/comments/306934906","html_url":"https://github.com/google/flatbuffers/issues/4306#issuecomment-306934906","issue_url":"https://api.github.com/repos/google/flatbuffers/issues/4306","id":306934906,"user":{"login":"llchan","id":51099,"avatar_url":"https://avatars1.githubusercontent.com/u/51099?v=3","gravatar_id":"","url":"https://api.github.com/users/llchan","html_url":"https://github.com/llchan","followers_url":"https://api.github.com/users/llchan/followers","following_url":"https://api.github.com/users/llchan/following{/other_user}","gists_url":"https://api.github.com/users/llchan/gists{/gist_id}","starred_url":"https://api.github.com/users/llchan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llchan/subscriptions","organizations_url":"https://api.github.com/users/llchan/orgs","repos_url":"https://api.github.com/users/llchan/repos","events_url":"https://api.github.com/users/llchan/events{/privacy}","received_events_url":"https://api.github.com/users/llchan/received_events","type":"User","site_admin":false},"created_at":"2017-06-07T21:47:04Z","updated_at":"2017-06-07T21:47:04Z","body":"The ideas described here have been merged into master :)"}}
{"actor":{"display_login":"llchan"}}