@@ -76,13 +76,17 @@ class SrsCoroutine : public ISrsStartable
76
76
// @return a copy of error, which should be freed by user.
77
77
// NULL if not terminated and user should pull again.
78
78
virtual srs_error_t pull () = 0;
79
+ // Get and set the context id of coroutine.
79
80
virtual const SrsContextId& cid () = 0;
81
+ virtual void set_cid (const SrsContextId& cid) = 0;
80
82
};
81
83
82
84
// An empty coroutine, user can default to this object before create any real coroutine.
83
85
// @see https://github.com/ossrs/srs/pull/908
84
86
class SrsDummyCoroutine : public SrsCoroutine
85
87
{
88
+ private:
89
+ SrsContextId cid_;
86
90
public:
87
91
SrsDummyCoroutine ();
88
92
virtual ~SrsDummyCoroutine ();
@@ -92,6 +96,7 @@ class SrsDummyCoroutine : public SrsCoroutine
92
96
virtual void interrupt ();
93
97
virtual srs_error_t pull ();
94
98
virtual const SrsContextId& cid ();
99
+ virtual void set_cid (const SrsContextId& cid);
95
100
};
96
101
97
102
// A ST-coroutine is a lightweight thread, just like the goroutine.
@@ -138,8 +143,9 @@ class SrsSTCoroutine : public SrsCoroutine
138
143
// @remark Return ERROR_THREAD_TERMINATED when thread terminated normally without error.
139
144
// @remark Return ERROR_THREAD_INTERRUPED when thread is interrupted.
140
145
virtual srs_error_t pull ();
141
- // Get the context id of thread.
146
+ // Get and set the context id of thread.
142
147
virtual const SrsContextId& cid ();
148
+ virtual void set_cid (const SrsContextId& cid);
143
149
};
144
150
145
151
// High performance coroutine.
@@ -180,6 +186,7 @@ class SrsFastCoroutine
180
186
return srs_error_copy (trd_err);
181
187
}
182
188
const SrsContextId& cid ();
189
+ virtual void set_cid (const SrsContextId& cid);
183
190
private:
184
191
srs_error_t cycle ();
185
192
static void * pfn (void * arg);
0 commit comments