Script "resource_queue.gd" in BackgroundLoading docs is same for Godot 3Х and Godot 4 versions, how to fix it?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By edd que

example (the file itself is the same) for 2 different versions of Godot 3X and 4,
I tried to redo it for godot 4, but there are no such methods: also in the documentation there is not yet a description of all methods, can someone help or update the example for the relevant version

error: Invalid call. Nonexistent function ‘set_meta’ in base ‘int’.

func queue_resource(path, p_in_front = false):
_lock("queue_resource")
if path in pending:
	_unlock("queue_resource")
	return
elif ResourceLoader.has_cached(path):
	var res = ResourceLoader.load(path)
	pending[path] = res
	_unlock("queue_resource")
	return
else: 
	var res = ResourceLoader.load_threaded_request(path)
	res.set_meta("path", path)
	if p_in_front:
		queue.insert(0, res)
	else:
		queue.push_back(res)
	pending[path] = res
	_post("queue_resource")
	_unlock("queue_resource")
	return