Alternative for serviceAsync<T>()?

2024.2+

I’m using coroutines a lot and started to use serviceAsync<ServiceType>() to fetch instances of service in a suspend context.

I now noticed that the method is @Internal.
Is it safe to use service<T>() instead or is there a public alternative for serviceAsync<T>()?

Thank you!

Hi!

We will try to relax access level there soon. Although you must know that serviceAsync means very little for real performance outside of the IDE startup sequence.

Thank you for your reply!

Is service() as non-suspending safe to use in a suspend context?
I’m not concerned about performance, services are not retrieved very often in my plugin.

It uses coroutines and cancellation inside anyway, should be safe. Also getting services without read action is something you should not usually do as any call may produce AlreadyDisposedException, since project / app may be disposed in parallel

1 Like