Commit 07a7e00a authored by Pavel Vainerman's avatar Pavel Vainerman

(CommonEventLoop): переделал на активацию только одного за один раз

(вместо списка)
parent 79617424
...@@ -511,6 +511,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -511,6 +511,9 @@ rm -f %buildroot%_libdir/*.la
* Tue Sep 12 2017 Alexei Takaseev <taf@altlinux.org> 2.6-alt19.1 * Tue Sep 12 2017 Alexei Takaseev <taf@altlinux.org> 2.6-alt19.1
- Rebuild with poco 1.7.9 - Rebuild with poco 1.7.9
# * Thu Jun 01 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt27
# - test build (devel)
# * Thu Jun 01 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt26 # * Thu Jun 01 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt26
# - test build (devel) # - test build (devel)
......
...@@ -116,7 +116,7 @@ namespace uniset ...@@ -116,7 +116,7 @@ namespace uniset
std::promise<bool>& result; std::promise<bool>& result;
}; };
std::queue<WatcherInfo> wactlist; std::shared_ptr<WatcherInfo> wact_info = { nullptr };
std::mutex wact_mutex; std::mutex wact_mutex;
ev::async evprep; ev::async evprep;
......
...@@ -54,17 +54,18 @@ namespace uniset ...@@ -54,17 +54,18 @@ namespace uniset
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool CommonEventLoop::activateWatcher( EvWatcher* w, size_t waitTimeout_msec ) bool CommonEventLoop::activateWatcher( EvWatcher* w, size_t waitTimeout_msec )
{ {
std::lock_guard<std::mutex> l(wact_mutex);
std::promise<bool> p; std::promise<bool> p;
WatcherInfo winfo(w,p); wact_info = std::make_shared<WatcherInfo>(w,p);
auto result = p.get_future();
{ auto result = p.get_future();
std::unique_lock<std::mutex> l(wact_mutex);
wactlist.push(winfo);
}
bool ret = true; bool ret = true;
if( !evprep.is_active() )
evprep.start();
// посылаем сигнал для обработки // посылаем сигнал для обработки
evprep.send(); // будим default loop evprep.send(); // будим default loop
...@@ -88,6 +89,7 @@ namespace uniset ...@@ -88,6 +89,7 @@ namespace uniset
} }
} }
wact_info = nullptr;
return ret; return ret;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -196,25 +198,18 @@ namespace uniset ...@@ -196,25 +198,18 @@ namespace uniset
return; return;
} }
{ if( !wact_info )
std::lock_guard<std::mutex> lock(wact_mutex); return;
while( !wactlist.empty() )
{
auto winf = wactlist.front();
wactlist.pop();
try try
{ {
winf.watcher->evprepare(loop); wact_info->watcher->evprepare(loop);
winf.result.set_value(true); wact_info->result.set_value(true);
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
cerr << "(CommonEventLoop::onPrepare): evprepare err: " << ex.what() << endl; cerr << "(CommonEventLoop::onPrepare): evprepare err: " << ex.what() << endl;
winf.result.set_value(false); wact_info->result.set_value(false);
}
}
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment