Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Is Parser generated by XText thread safe?
Is Parser generated by XText thread safe? [message #1763673] Thu, 18 May 2017 13:28 Go to next message
Mikhail Mukhin is currently offline Mikhail MukhinFriend
Messages: 1
Registered: May 2017
Junior Member
Hello, does anybody know - is the Parser, generated by XText, thread safe and reusable?

I have MyDslParser extends AbstractAntlrParser, so I create the instance like this:
MyDslParser parser = new MyDslParser ();
new DslStandaloneSetup()
     .createInjectorAndDoEMFRegistration()
     .injectMembers(parser);


Can I reuse this instance in many threads?
Re: Is Parser generated by XText thread safe? [message #1763907 is a reply to message #1763673] Mon, 22 May 2017 18:46 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

No it is not thread safe, since it is building an EMF AST and EMF itself is not thread safe.
Re: Is Parser generated by XText thread safe? [message #1763910 is a reply to message #1763907] Mon, 22 May 2017 19:40 Go to previous message
Ed Willink is currently online Ed WillinkFriend
Messages: 7671
Registered: July 2009
Senior Member
Hi

EMF is thread safe provided you warm up properly and use it right.

What do you really want to do on multiple threads?

If you want a single parse wrapped up in an IUnitOfWork on an indeterminate thread, it should work, though I'd be inclined to serialize all parses through a dedicated Parser thread.

If you want to re-use the parser many times for independent parses on different threads, who knows? My instinct is that there is too much clever declarative stuff going on to be sure that caches are not going to evolve.

If you want to throw multiple threads at the parser to accelerate it. No chance.

Regards

Ed Willink

Previous Topic:Targeting both eclipse and LSP
Next Topic:Loading Xtext Resource Into EMF Editor Breaks on Save?
Goto Forum:
  


Current Time: Thu Sep 26 10:58:33 GMT 2024

Powered by FUDForum. Page generated in 0.03793 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top