Skip to content

Commit 7d2598f

Browse files
committed
Synchronize access to the Prism instance
WASM is inherently single-threaded, so we cannot allow multiple threads to be parsing with a single chicory-prism instance at the same time. For now, we synchronize that access. A pool of instances or a soft thread-local could be used in the future if that becomes a bottleneck.
1 parent bc1a9b5 commit 7d2598f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/main/java/org/jruby/prism/parser/ParserPrismWasm.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
import org.jruby.Ruby;
44
import org.prism.Prism;
5-
import org.prism.PrismWASM;
65

76
public class ParserPrismWasm extends ParserPrismBase {
8-
private static final Prism prism = new PrismWASM();
7+
private final Prism prism = new Prism();
98

109
public ParserPrismWasm(Ruby runtime) {
1110
super(runtime);
1211
}
1312

14-
protected byte[] parse(byte[] source, int sourceLength, byte[] metadata) {
13+
protected synchronized byte[] parse(byte[] source, int sourceLength, byte[] metadata) {
1514
return prism.serialize(metadata, source, sourceLength);
1615
}
1716
}

0 commit comments

Comments
 (0)