Thread: Vapoursynth
View Single Post
Old 21st November 2020, 20:10   #4186  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I can't decide which is the correct design for message handlers.
should I bind the lifetime of a message handler to its descriptor, like a file descriptor?
Code:
auto md = Core.AddMessageHandler([](auto...) {});
// md is a stateful object
// automatically calls removeMessageHandler() in md's destructor when it goes out of scope
or should I let the user manage the handler's lifetime manually?
Code:
auto md = Core.AddMessageHandler([](auto...) {});
// md is a stateless integer ID / pointer

Core.Eject(md);
// explicitly ejects the handler when no longer needed.
feisty2 is offline   Reply With Quote