2 ms·
After looking at the examples, it looks to me that it uses a hashmap (with a generated token to identify the connection structure). It gets around putting a pt
by lelanthran 5y ago
After looking at the examples, it looks to me that it uses a hashmap (with a generated token to identify the connection structure).
It gets around putting a ptr into the event structure (that epoll will then return) by putting a tokenID into it instead (that epoll returns), that the connection_handler function will then use to retrieve the connection instance that it needs to work with.
IOW, in `C` I'd create an instance of a `struct connection_t` and `epoll_wait()` returns the pointer to the instance.
This way, it appears that an ID is placed into the event structure and the { ID : corresponding instance } tuple is stored in a hashmap. `epoll_wait()` returns the ID, the caller uses that ID to get an instance to work with.
Although, I could be wrong - I'm not a Rust dev.