Skip to content
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

Merged
merged 2 commits into from
Mar 5, 2018

Conversation

tribal-tec
Copy link
Contributor

  • 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

@tribal-tec
Copy link
Contributor Author

retest this please

@tribal-tec tribal-tec force-pushed the event_loop branch 2 times, most recently from 2429161 to 693c36e Compare February 22, 2018 14:13
@tribal-tec tribal-tec force-pushed the event_loop branch 3 times, most recently from 052cdb0 to 181388f Compare February 23, 2018 14:55
Copy link

@rdumusc rdumusc left a 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!

const float idleRenderingDelay = 0.1f;
bool isLoading = false;
brayns::Timer timeSinceLastEvent;
{
Copy link

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?

checkIdleRendering->on<uvw::CheckEvent>(
[&](const auto&, auto&) { accumRendering->start(); });

// render trigger from going into idle
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from -> for?

brayns.createPlugins();

// Start render & main loop
std::thread renderThread([&] { renderLoop->run(); });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[&renderLoop]

std::bind(&Brayns::Impl::_loadScene, this));
std::async(std::launch::deferred,
std::bind(&Brayns::Impl::_loadScene, this))
.get();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? _loadScene(this); ?

Copy link
Contributor Author

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 :)

Copy link

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 :-)

@@ -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;
Copy link

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;
Copy link

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)
Copy link
Member

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?

Copy link
Contributor Author

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.


brayns::Brayns brayns(argc, argv);

auto mainLoop = uvw::Loop::getDefault();
Copy link
Member

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.

@favreau
Copy link
Member

favreau commented Mar 5, 2018

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
@tribal-tec tribal-tec merged commit 9d203de into BlueBrain:master Mar 5, 2018
@tribal-tec tribal-tec deleted the event_loop branch March 5, 2018 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants