static int socket_next_id(void) { int i; for (i = 0; i < MAX_SOCKET; i++) { struct socket *sock; int id = atom_inc(&(S.next_id)); if (id < 0) { id = atom_and(&(S.next_id), 0x7fffffff); } sock = &S.slot[HASH_ID(id)]; if (sock->type == SOCKET_TYPE_INVALID) { if (atom_cas(&(sock->type), SOCKET_TYPE_INVALID, SOCKET_TYPE_RESERVE)) { sock->id = id; sock->fd = -1; return id; } --i; } } return -1; }
variable<T> atom_and( const detail::uav_expression_base<T,E,C>& uav, const typename T::component_type& v1 ) { return atom_and(uav,detail::value<T>(v1)); }