Closed Christina2333 closed 2 years ago
Yes, the issue in your code is that the first closure attempts to borrow the event_loop
from the main function.
You can avoid that by creating an explicit variable let handle = event_loop.handle()
in your main function, and then using handle
instead of event_loop.handle()
in your callback. You'll also need to define the closure as capturing its environment by value, using the move
keyword: move |event, metadata, shared_data| { ... }
.
Thanks!! It works.
I'm trying to write a server with calloop that handles read and write events. First, The event loop should listen to the server socket and wait for the client to connect. Second, If a client connects to this socket, the event loop will process read write events from the client.
I get the following error when running:
I'm confused about that. Can callback functions be nested? Or there is another way to deal with. Thanks a lot.