Skip to content

Async reflection can be delayed  #34

@TPGamesNL

Description

@TPGamesNL

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions