Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async reflection can be delayed #34

Closed
TPGamesNL opened this issue Jan 20, 2021 · 0 comments
Closed

Async reflection can be delayed #34

TPGamesNL opened this issue Jan 20, 2021 · 0 comments
Labels
bug Something isn't working priority: low

Comments

@TPGamesNL
Copy link
Member

Because of https://github.com/TPGamesNL/skript-reflect/blob/2.x/src/main/java/com/btk5h/skriptmirror/skript/EffExpressionStatement.java#L27 the maximum number of simultaneously running reflection calls is limited by the return value of above method. Example:

import:
	java.lang.Thread
	java.lang.Runnable
	java.lang.System
	java.lang.Runtime

function test(proxy: object):
	await {_proxy}.run()

command /test:
	trigger:
		broadcast "availableProcessors: %Runtime.getRuntime().availableProcessors()%"
		set {_start} to now
		loop 5 times:
			set {_i} to loop-value
			create section stored in {_f::run}:
				broadcast "[%{_i}%] started @ %difference between {_start} and now%"
				Thread.sleep(1000)
			set {_proxy::%{_i}%} to proxy of Runnable from {_f::*}
		loop 5 times:
			test({_proxy::%loop-value%})

output:

availableProcessors: 4
[3] started @ 0.001 seconds
[1] started @ 0.001 seconds
[4] started @ 0.001 seconds
[2] started @ 0.002 seconds
[5] started @ 1.002 seconds
@TPGamesNL TPGamesNL added bug Something isn't working priority: low labels Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: low
Projects
None yet
Development

No branches or pull requests

1 participant