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

Function StreamWait

src/brpc/stream.cpp:796–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796void StreamWait(StreamId stream_id, const timespec *due_time,
797 void (*on_writable)(StreamId, void*, int), void *arg) {
798 SocketUniquePtr ptr;
799 if (Socket::Address(stream_id, &ptr) != 0) {
800 Stream::WritableMeta* wm = new Stream::WritableMeta;
801 wm->id = stream_id;
802 wm->arg= arg;
803 wm->has_timer = false;
804 wm->on_writable = on_writable;
805 wm->error_code = EINVAL;
806 const bthread_attr_t* attr =
807 FLAGS_usercode_in_pthread ? &BTHREAD_ATTR_PTHREAD
808 : &BTHREAD_ATTR_NORMAL;
809 bthread_t tid;
810 if (bthread_start_background(&tid, attr, Stream::RunOnWritable, wm) != 0) {
811 PLOG(FATAL) << "Fail to start bthread";
812 Stream::RunOnWritable(wm);
813 }
814 return;
815 }
816 Stream* s = (Stream*)ptr->conn();
817 return s->Wait(on_writable, arg, due_time);
818}
819
820int StreamWait(StreamId stream_id, const timespec* due_time) {
821 SocketUniquePtr ptr;

Callers 2

TEST_FFunction · 0.85

Calls 2

bthread_start_backgroundFunction · 0.85
WaitMethod · 0.45

Tested by 2

TEST_FFunction · 0.68