You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once #1772 is fully implemented, both the Runtime's Compiler (when resolving imports) and the Language Server (on user's library/preinstall request) will be able to install libraries. If two processes try installing the same library at the same time, it can become corrupted or the process may fail - to avoid this we have a synchronization mechanism in place.
However due to JVM limitations, the FileLockManager can only synchronize distinct JVMs. To aid this, we created a ThreadSafeFileLockManager which, when shared within a single JVM, is able to synchronize threads within a single JVM and within distinct JVMs at the same time.
Our scenario however is more complicated - the Language Server and Runtime do run on the same JVM, but due to Classpath Separation, they cannot that easily share an instance of ThreadSafeFileLockManager.
This task consists of creating a LockManager conforming wrapper which will allow to synchronize installation operations happening on both sides - in the Language Server as well as the Runtime.
To achieve that, we need to create a wrapper for LockManager that will live in the runtime, which will use Truffle's serverTransport and MessageEndpointreuse the RuntimeServerInstrument and its connection to communicate with a ThreadSafeLockManager instance running in the language-server.
Libraries can be safely installed both in the Language Server and the Runtime.
Specification
Create a simple protocol for the lock manager.
Implement a LockManager which will use the MessageEndpoint to send lock requests and handle responses. It should ensure that it will be used from a single thread or should otherwise be thread-safe.
Use the serverTransport functionality to bind the MessageEndpoint to a service which will pass the aforementioned requests to the language server's instance of ThreadSafeLockManager.
Make it possible to send requests using RuntimeServerConnector in both directions.
Redirect lock requests to the LockManagerService which wraps an underlying ThreadSafeLockManager.
Create a ConnectedLockManager that connects to an Endpoint and passes the lock requests to the Language Server using the runtime connector mechanism.
When creating the context, if running in Language Server mode, connect to the LS's lock manager using the mechanism created above; in text mode create a local ThreadSafeFileLockManager.
Acceptance Criteria & Test Cases
The above specification has been completed.
Test the ConnectedLockManager by connecting it to the LockManagerService.
Manually test the language server with the IDE to make sure that nothing is broken.
The text was updated successfully, but these errors were encountered:
Summary
Once #1772 is fully implemented, both the Runtime's Compiler (when resolving imports) and the Language Server (on user's
library/preinstall
request) will be able to install libraries. If two processes try installing the same library at the same time, it can become corrupted or the process may fail - to avoid this we have a synchronization mechanism in place.However due to JVM limitations, the FileLockManager can only synchronize distinct JVMs. To aid this, we created a ThreadSafeFileLockManager which, when shared within a single JVM, is able to synchronize threads within a single JVM and within distinct JVMs at the same time.
Our scenario however is more complicated - the Language Server and Runtime do run on the same JVM, but due to Classpath Separation, they cannot that easily share an instance of
ThreadSafeFileLockManager
.This task consists of creating a
LockManager
conforming wrapper which will allow to synchronize installation operations happening on both sides - in the Language Server as well as the Runtime.To achieve that, we need to create a wrapper for
LockManager
that will live in the runtime, which willuse Truffle'sreuse the RuntimeServerInstrument and its connection to communicate with aserverTransport
andMessageEndpoint
ThreadSafeLockManager
instance running in the language-server.It would be best to implement this before #1772.
Value
Specification
Implement aLockManager
which will use theMessageEndpoint
to send lock requests and handle responses. It should ensure that it will be used from a single thread or should otherwise be thread-safe.Use theserverTransport
functionality to bind theMessageEndpoint
to a service which will pass the aforementioned requests to the language server's instance ofThreadSafeLockManager
.ThreadSafeFileLockManager
.Acceptance Criteria & Test Cases
The text was updated successfully, but these errors were encountered: