File tree Expand file tree Collapse file tree 2 files changed +12
-24
lines changed Expand file tree Collapse file tree 2 files changed +12
-24
lines changed Original file line number Diff line number Diff line change @@ -202,28 +202,6 @@ void EventLoop::abortNotInLoopThread()
202
202
" thread" ;
203
203
exit (1 );
204
204
}
205
- void EventLoop::runInLoop (const Func &cb)
206
- {
207
- if (isInLoopThread ())
208
- {
209
- cb ();
210
- }
211
- else
212
- {
213
- queueInLoop (cb);
214
- }
215
- }
216
- void EventLoop::runInLoop (Func &&cb)
217
- {
218
- if (isInLoopThread ())
219
- {
220
- cb ();
221
- }
222
- else
223
- {
224
- queueInLoop (std::move (cb));
225
- }
226
- }
227
205
void EventLoop::queueInLoop (const Func &cb)
228
206
{
229
207
funcs_.enqueue (cb);
Original file line number Diff line number Diff line change @@ -121,8 +121,18 @@ class TRANTOR_EXPORT EventLoop : NonCopyable
121
121
* @note If the current thread is the thread of the event loop, the function
122
122
* f is executed directly before the method exiting.
123
123
*/
124
- void runInLoop (const Func &f);
125
- void runInLoop (Func &&f);
124
+ template <typename Functor>
125
+ inline void runInLoop (Functor &&f)
126
+ {
127
+ if (isInLoopThread ())
128
+ {
129
+ f ();
130
+ }
131
+ else
132
+ {
133
+ queueInLoop (std::forward<Functor>(f));
134
+ }
135
+ }
126
136
127
137
/* *
128
138
* @brief Run the function f in the thread of the event loop.
You can’t perform that action at this time.
0 commit comments