Skip to content

Commit 71f454a

Browse files
ryanmeiera-maurice
authored andcommitted
Moving scheduler thread creation from ctor (which gets called statically) to Schedule().
PiperOrigin-RevId: 249840945
1 parent 6eb9a90 commit 71f454a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/src/scheduler.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ Scheduler::Scheduler()
6767
next_request_id_(0),
6868
terminating_(false),
6969
request_mutex_(Mutex::kModeRecursive),
70-
sleep_sem_(0) {
71-
thread_ = new Thread(WorkerThreadRoutine, this);
72-
}
70+
sleep_sem_(0) {}
7371

7472
Scheduler::~Scheduler() {
7573
CancelAllAndShutdownWorkerThread();
@@ -100,6 +98,10 @@ RequestHandle Scheduler::Schedule(callback::Callback* callback,
10098

10199
MutexLock lock(request_mutex_);
102100

101+
if (!thread_ && !terminating_) {
102+
thread_ = new Thread(WorkerThreadRoutine, this);
103+
}
104+
103105
RequestDataPtr request(
104106
new RequestData(++next_request_id_, callback, delay, repeat));
105107

0 commit comments

Comments
 (0)