Example #1
0
struct ast_taskprocessor *ast_threadpool_serializer_group(const char *name,
	struct ast_threadpool *pool, struct ast_serializer_shutdown_group *shutdown_group)
{
	struct serializer *ser;
	struct ast_taskprocessor_listener *listener;
	struct ast_taskprocessor *tps;

	ser = serializer_create(pool, shutdown_group);
	if (!ser) {
		return NULL;
	}

	listener = ast_taskprocessor_listener_alloc(&serializer_tps_listener_callbacks, ser);
	if (!listener) {
		ao2_ref(ser, -1);
		return NULL;
	}
	/* ser ref transferred to listener */

	tps = ast_taskprocessor_create_with_listener(name, listener);
	if (tps && shutdown_group) {
		serializer_shutdown_group_inc(shutdown_group);
	}

	ao2_ref(listener, -1);
	return tps;
}
Example #2
0
static struct serializer *serializer_find_or_create(const char *aor_name)
{
	struct serializer *ser = ao2_find(serializers, aor_name, OBJ_SEARCH_KEY);

	if (ser) {
		return ser;
	}

	if (!(ser = serializer_create(aor_name))) {
		return NULL;
	}

	ao2_link(serializers, ser);
	return ser;
}