-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event-driven architecture for braynsService, resolve #286 #314
Conversation
tribal-tec
commented
Feb 22, 2018
- use libuv and uvw as an event-loop
- extend Brayns to use threaded and event-driven rendering in braynsService
- braynsViewer remains untouched in its behavior
- introduce cancel for snapshots
retest this please |
2429161
to
693c36e
Compare
052cdb0
to
181388f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the libuv integration is very clean and simple as far as I can see. Good job!
apps/BraynsService/main.cpp
Outdated
const float idleRenderingDelay = 0.1f; | ||
bool isLoading = false; | ||
brayns::Timer timeSinceLastEvent; | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this scope for? couldn't the main() be shortened a bit too?
apps/BraynsService/main.cpp
Outdated
checkIdleRendering->on<uvw::CheckEvent>( | ||
[&](const auto&, auto&) { accumRendering->start(); }); | ||
|
||
// render trigger from going into idle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from -> for?
apps/BraynsService/main.cpp
Outdated
brayns.createPlugins(); | ||
|
||
// Start render & main loop | ||
std::thread renderThread([&] { renderLoop->run(); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[&renderLoop]
brayns/Brayns.cpp
Outdated
std::bind(&Brayns::Impl::_loadScene, this)); | ||
std::async(std::launch::deferred, | ||
std::bind(&Brayns::Impl::_loadScene, this)) | ||
.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? _loadScene(this); ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, most complicated function call ever :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahaha I really wondered what was happening here :-)
brayns/common/renderer/Renderer.h
Outdated
@@ -31,14 +31,12 @@ class Renderer | |||
public: | |||
BRAYNS_API Renderer(ParametersManager& parametersManager); | |||
virtual ~Renderer() {} | |||
virtual void render(FrameBufferPtr frameBuffer) = 0; | |||
virtual float render(FrameBufferPtr frameBuffer) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think render() should return a float. It's not obvious what it means, and it's not even documented. I would suggest having a separate getter for that float value.
|
||
void onDeleteSocket(const rockets::SocketDescriptor fd) final; | ||
|
||
std::function<void()> postReceive; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small detail, but I would have made it private with a setter only, if it's never accessed outside the class.
CMakeLists.txt
Outdated
|
||
if(libuv_FOUND) | ||
if(libuv_VERSION VERSION_LESS 1.9.0) | ||
add_definitions(-DUV_DISCONNECT=4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this UV_DISCONNECT=4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not defined in the ancient libuv version of Ubuntu 16.04, but the uvw C++ wrapper library needs it. I couldn't go further back for an old enough version of uvw, so that's the shortest path to make things work.
apps/BraynsService/main.cpp
Outdated
|
||
brayns::Brayns brayns(argc, argv); | ||
|
||
auto mainLoop = uvw::Loop::getDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All variables can be const.
I did some quite intensive testing last week and this PR clearly improves and stabilizes Brayns, especially with external components (notebooks and web UI). Nice work!! |
* use libuv and uvw as an event-loop * extend Brayns to use threaded and event-driven rendering in braynsService * braynsViewer remains untouched in its behavior * introduce cancel for snapshots