MCPcopy Create free account
hub / github.com/apache/brpc / GetChunkStream

Method GetChunkStream

src/brpc/policy/rtmp_protocol.cpp:829–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

827}
828
829RtmpChunkStream* RtmpContext::GetChunkStream(uint32_t cs_id) {
830 if (cs_id > RTMP_MAX_CHUNK_STREAM_ID) {
831 LOG(ERROR) << "Invalid chunk_stream_id=" << cs_id;
832 return NULL;
833 }
834 const uint32_t index1 = cs_id / RTMP_CHUNK_ARRAY_2ND_SIZE;
835 SubChunkArray* sub_array =
836 _cstream_ctx[index1].load(butil::memory_order_consume);
837 if (sub_array == NULL) {
838 // Optimistic creation.
839 sub_array = new SubChunkArray;
840 SubChunkArray* expected = NULL;
841 if (!_cstream_ctx[index1].compare_exchange_strong(
842 expected, sub_array, butil::memory_order_acq_rel)) {
843 delete sub_array;
844 sub_array = expected;
845 }
846 }
847 const uint32_t index2 = cs_id - index1 * RTMP_CHUNK_ARRAY_2ND_SIZE;
848 RtmpChunkStream* cstream =
849 sub_array->ptrs[index2].load(butil::memory_order_consume);
850 if (cstream == NULL) {
851 // Optimistic creation.
852 cstream = new RtmpChunkStream(this, cs_id);
853 RtmpChunkStream* expected = NULL;
854 if (!sub_array->ptrs[index2].compare_exchange_strong(
855 expected, cstream, butil::memory_order_acq_rel)) {
856 delete cstream;
857 cstream = expected;
858 }
859 }
860 return cstream;
861}
862
863void RtmpContext::ClearChunkStream(uint32_t cs_id) {
864 if (cs_id > RTMP_MAX_CHUNK_STREAM_ID) {

Callers 1

AppendAndDestroySelfMethod · 0.80

Calls 2

loadMethod · 0.45

Tested by

no test coverage detected