Multiple XMI Resources concurrently [message #834768] |
Mon, 02 April 2012 07:18  |
Eclipse User |
|
|
|
Hi,
I have an Ecore resource and using that i am trying to make multiple XMI resources using multithreading. I am using delegates to evaluate the instance model. If i use one thread every thing works fine but when i try to use multithreading then on creating xmi resource i get null pointer exception and setting delegate also becomes unable to calculate derivation statements.
Even if i will try to create XMI resource in synchronized block, it will be the same situation.
I need xmi resource as i am using allInstance statements.
Any idea?
Cheers,
|
|
|
|
|
|
Re: Multiple XMI Resources concurrently [message #835078 is a reply to message #835054] |
Mon, 02 April 2012 15:16   |
Eclipse User |
|
|
|
Ed,
Comments below.
On 02/04/2012 11:36 AM, Ed Willink wrote:
> Hi
>
> EMF claims to be threadsafe, and with the possible exception of
> delegates, probably is.
What's the issue with setting delegates? I can see a race condition in
their initialization (EStructuralFeatureImpl.getSettingDelegate), but it
shouldn't matter if the delegate is initialized more than once...
>
> Eclipse OCL makes no such claims and clearly isn't.
>
> If you want to operate beyond the claimed capabilities, it is for you
> to debug your problems, some of which may be yours rather than Eclipse
> OCL's.
>
> I gave you a possible warm up procedure that just might work. It does
> all the dangerous things in one thread, then does only safe things in
> other threads. This strategy might avoid the problems. With knowledge
> of your application you may be able to apply other strategies.
>
> But if you really want multi-threading, you may want to fix the thread
> safety and contribute a patch so that others can benefit.
>
> Regards
>
> Ed Willink
>
> On 02/04/2012 14:11, ModelGeek Mising name wrote:
>> Thanks!
>>
>> but can i create multiple XMI resources with multithreading like
>>
>> URI uri = URI.createFileURI(number + "temp.xmi");
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
>> new XMIResourceFactoryImpl());
>> Resource resource = resourceSet.createResource(uri);
>> resource.getContents().addAll(table.values());
>>
>> this piece of code is defined in thread's run method but in some
>> thread i get the NPE
>> on last line means resource object is null in some cases. Is it also
>> known problem or i am doing something wrong?
>>
>> Thanks alot for assitance
>>
>> Cheers
>
|
|
|
Re: Multiple XMI Resources concurrently [message #835131 is a reply to message #835078] |
Mon, 02 April 2012 16:47  |
Eclipse User |
|
|
|
Hi Ed
On 02/04/2012 20:16, Ed Merks wrote:
>> EMF claims to be threadsafe, and with the possible exception of
>> delegates, probably is.
>
> What's the issue with setting delegates? I can see a race condition
> in their initialization (EStructuralFeatureImpl.getSettingDelegate),
> but it shouldn't matter if the delegate is initialized more than once...
I scanned the code in response to a similar query perhaps six months ago
and didn't get the impression that the code was inherently safe. It may
just be a benign race condition, but ... it's recent code. It was not
apparent that multi-threading was a design issue in the patches; if it
was, I would have tried harder on the OCL extension. I'm not sure that
multi-threading has ever been tested, so I think a possible
question-mark over delegate thread safety is appropriate to draw users
attention to.
Regards
Ed
|
|
|
Powered by
FUDForum. Page generated in 0.07751 seconds