示例#1
0
文件: timeout.c 项目: junaidk/uhub
void timeout_queue_remove(struct timeout_queue* t, struct timeout_evt* evt)
{
	size_t pos = (evt->timestamp % t->max);
	struct timeout_evt* first = t->events[pos];

	if (!first || !evt->prev)
		return;

	if (first == evt)
	{
		if (first->prev != first)
		{
			t->events[pos] = first->next;
			t->events[pos]->prev = evt->prev;
		}
		else
		{
			t->events[pos] = 0;
		}
	}
	else if (evt == first->prev)
	{
		first->prev = evt->prev;
		evt->prev->next = 0;
	}
	else
	{
		evt->prev->next = evt->next;
		evt->next->prev = evt->prev;
	}
	timeout_evt_reset(evt);
}
示例#2
0
文件: timeout.c 项目: leejb521/uhub
static void timeout_queue_remove_locked(struct timeout_queue* t, struct timeout_evt* evt)
{
	uhub_assert(evt->prev == &t->lock);
	if (t->lock.next == evt)
	{
		t->lock.next = evt->next;
		if (t->lock.prev == evt)
			t->lock.prev = evt->next;
	}
	else
	{
		struct timeout_evt *prev, *it;
		prev = 0;
		it = t->lock.next;
		while (it)
		{
			prev = it;
			it = it->next;
			if (it == evt)
			{
				prev->next = it->next;
				if (!prev->next)
					t->lock.prev = prev;
			}
		}
	}
	timeout_evt_reset(evt);
}