我正在撰写一份客户服务申请,并使用POSIXpoll
功能,提供一种同时处理客户的方式。 客户也有国家数据和其他相关数据,储存在客户结构中。
My immediate problem is that when I get a hint from poll
to do I/O on a socket file descriptor that is associated with a client (conceptually), I have to actually match the file descriptor to its associated client data structure. Currently I do a O(n_clients)
lookup (my client data structure stores the descriptor), but I was wondering whether there exists a better alternative?