Beispiel #1
0
void 
skynet_handle_retireall() {
	struct handle_storage *s = H;
	for (;;) {	// 保证所有的资源都被回收

		int n = 0;
		int i;
		for (i = 0; i < s->slot_size; i++) {
			// 保证线程安全
			rwlock_rlock(&s->lock);

			// 拿到 context 的 handle
			struct skynet_context * ctx = s->slot[i];
			uint32_t handle = 0;
			if (ctx)
				handle = skynet_context_handle(ctx);

			rwlock_runlock(&s->lock);

			// 对 handle 做回收处理
			if (handle != 0) {		// 这就是上面说的, handle 不会使用 0.
				if (skynet_handle_retire(handle)) {
					++n;
				}
			}
		}

		// 保证全部的 context 全部删除
		if (n==0)
			return;
	}
}
Beispiel #2
0
void 
skynet_handle_retireall() {
	struct handle_storage *s = H;
	for (;;) {
		int n=0;
		int i;
		for (i=0;i<s->slot_size;i++) {
			rwlock_rlock(&s->lock);
			struct skynet_context * ctx = s->slot[i];
			rwlock_runlock(&s->lock);
			if (ctx != NULL) {
				++n;
				skynet_handle_retire(skynet_context_handle(ctx));
			}
		}
		if (n==0)
			return;
	}
}
Beispiel #3
0
void 
skynet_handle_retireall() {
	struct handle_storage *s = H;
	for (;;) {
		int n=0;
		int i;
		for (i=0;i<s->slot_size;i++) {
			rwlock_rlock(&s->lock);
			struct skynet_context * ctx = s->slot[i];
			uint32_t handle = 0;
			if (ctx)
				handle = skynet_context_handle(ctx);
			rwlock_runlock(&s->lock);
			if (handle != 0) {
				if (skynet_handle_retire(handle)) {
					++n;
				}
			}
		}
		if (n==0)
			return;
	}
}