[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
CAPE-OPEN • View topic - COFE collapses when using CoUninitialize in destruction

COFE collapses when using CoUninitialize in destruction

Discusses use of COCO, the process simulation and modelling software suite from AmsterCHEM, downloadable from http://www.cocosimulator.org

Moderator: jasper

COFE collapses when using CoUninitialize in destruction

Postby bcbooo » 10 August 2014, 08:29

Attachments
Untitled.jpg
error window
Untitled.jpg (232.15 KiB) Viewed 25262 times
bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: COFE collapses when using CoUninitialize in destruction

Postby jasper » 10 August 2014, 09:26

There are two things of your mail rather unclear to me:

1) why would a PMC call CoInitialize and CoUninitialize? I presume your unit operation is a CAPE-OPEN COM object, so the COM initialization is already done by the PME that created your unit operation. What is your point of re-initializing COM?

2) why would a unit operation create an object that implements ICapeThermoCompounds?
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE collapses when using CoUninitialize in destruction

Postby jasper » 10 August 2014, 09:29

To answer your question about the second CoCreateInstance: by default COFE does not solve in the main thread. It solves in a background thread. As COFE uses the apartment threaded model, it cannot use the unit operations from the main thread in the solution thread. Therefore, it saves the one in the main thread, creates a new one in the solution thread, and restores it from the saved one. Now there are two copies; one in the main thread and one in the solution thread.

You can turn this off (in preferences you can untick the box to use a separate thread for solutions) but now solving is done in the main thread, which makes the application respond less. More-over, this is the calling pattern to be expected in any multi-threaded CAPE-OPEN application. See here for more info:

User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE collapses when using CoUninitialize in destruction

Postby bcbooo » 11 August 2014, 02:23

bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: COFE collapses when using CoUninitialize in destruction

Postby jasper » 11 August 2014, 07:14

Is tc a shared resource (e.g. a global variable, or a static variable)? How is it declared?

If there is only one copy of tc I would expect things to go wrong indeed.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE collapses when using CoUninitialize in destruction

Postby bcbooo » 11 August 2014, 07:37

bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: COFE collapses when using CoUninitialize in destruction

Postby jasper » 11 August 2014, 07:53

Why do you not make it a class variable?
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE collapses when using CoUninitialize in destruction

Postby jasper » 11 August 2014, 07:55

Alternatively, is this is an object to be shared by multiple unit operations, keep a reference count on it. Delete it when the last unit operation is deleted.

But this will surely give you thread safety problems. Suppose you have two threads that each have a unit operation, and that are calculating at the same time; they will be accessing the tc object simultaneously. You would need to synchronize access to this object.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE collapses when using CoUninitialize in destruction

Postby bcbooo » 11 August 2014, 08:05

tc is not shared by multiple Unit Operations, but shared by many functions in different classes. In my application tc is used to get some public data.

Now my strategy is not to call "tc=NULL" in destruction.
bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: COFE collapses when using CoUninitialize in destruction

Postby jasper » 11 August 2014, 08:29

This will not resolve your conflict regarding tc being used by two different unit operations. I suggest you make tc a member variable of the unit operation class.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain


Return to COCO (AmsterCHEM)

Who is online

Users browsing this forum: No registered users and 9 guests