Closed davidcorrigan714 closed 9 months ago
Yes, I believe that the PhantomData
is not working as intended. The original intent here was to prevent the service from being dropped before the EventLoop
, but I think this was a mistake. Admittedly, I was new to the language at the time and hadn't quite wrapped my head around lifetimes yet.
I have a branch (refactor/arc-rc) that I started a few weeks ago that should resolve this issue by removing the lifetime parameter entirely; instead managing the early-drop problem using Rc
s. I will try to wrap that work up soon™️.
I'll have to peak at that branch. The Rcs almost seemed to cause more problems than they solve. May make sense for the EventLoop to just take a reference to poll. When the service drops it just drops a whole bunch of stuff, like the client and context so just keeping poll alive isn't all that helpful.
This should be fixed in 0.14.0
, let me know if you have any issues. Also, just FYI, you should probably be using MdnsService
instead of AvahiMdnsService
and EventLoop
instead of AvahiEventLoop
.
Having a hard time figuring out a solution to this lifetime problem. Essentially I have a worker thread for registering mdns entries, each of which requires an MdnsService and an EventLoop. Somehow creating the EventLoop is holding a mutable borrow to the MdnsService and I can't quite figure out how to handle the lifetimes. My code is:
I get the error:
It seems to have something to do with how PhantomData in AvahiEventLoop is capturing the mutable borrow, but can't quite tell if there's a way to handle this in my code or if the library really needs to change. I've tried various permutations of Rc & RefCell around new_service but that doesn't seem to help with checking the ownership of that borrow on 141.