@@ -67,7 +67,7 @@ void ConcurrentScheduler::init(int32 threads_n) {
6767void ConcurrentScheduler::test_one_thread_run () {
6868 do {
6969 for (auto &sched : schedulers_) {
70- sched->run (0 );
70+ sched->run (Timestamp::now_cached () );
7171 }
7272 } while (!is_finished_.load (std::memory_order_relaxed));
7373}
@@ -85,7 +85,7 @@ void ConcurrentScheduler::start() {
8585 td::detail::Iocp::Guard iocp_guard (iocp_.get ());
8686#endif
8787 while (!is_finished ()) {
88- sched->run (10 );
88+ sched->run (Timestamp::in ( 10 ) );
8989 }
9090 }));
9191 }
@@ -99,8 +99,9 @@ void ConcurrentScheduler::start() {
9999
100100 state_ = State::Run;
101101}
102+ static TD_THREAD_LOCAL double emscripten_timeout;
102103
103- bool ConcurrentScheduler::run_main (double timeout) {
104+ bool ConcurrentScheduler::run_main (Timestamp timeout) {
104105 CHECK (state_ == State::Run);
105106 // run main scheduler in same thread
106107 auto &main_sched = schedulers_[0 ];
@@ -110,9 +111,25 @@ bool ConcurrentScheduler::run_main(double timeout) {
110111#endif
111112 main_sched->run (timeout);
112113 }
114+
115+ // hack for emscripten
116+ emscripten_timeout = get_main_timeout ().at ();
117+
113118 return !is_finished ();
114119}
115120
121+ Timestamp ConcurrentScheduler::get_main_timeout () {
122+ CHECK (state_ == State::Run);
123+ return schedulers_[0 ]->get_timeout ();
124+ }
125+
126+ double ConcurrentScheduler::emscripten_get_main_timeout () {
127+ return Timestamp::at (emscripten_timeout).in ();
128+ }
129+ void ConcurrentScheduler::emscripten_clear_main_timeout () {
130+ emscripten_timeout = 0 ;
131+ }
132+
116133void ConcurrentScheduler::finish () {
117134 CHECK (state_ == State::Run);
118135 if (!is_finished ()) {
0 commit comments