octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread-safety issues in QtHandles


From: Michael Goffioul
Subject: Re: Thread-safety issues in QtHandles
Date: Mon, 31 Oct 2011 09:29:41 +0000

On Mon, Oct 31, 2011 at 5:19 AM, John W. Eaton <address@hidden> wrote:
> On 30-Oct-2011, Michael Goffioul wrote:
>
> | The main problem is that when using shared_ptr, the underlying class
> | does not have any counter anymore, as it's managed by the shared_ptr.
> | However, there are various places where the "count" member is used,
> | for instance to return itself (octave_base_value*) wrapped in an
> | octave_value object. Typical example is the subsasgn method.
>
> Right, the idea there is to increment the count so that the object
> that is being wrapped won't be deleted early.  Maybe that is not an
> issue with a shared_ptr?  I don't know, as I don't understand
> precisely how it is supposed to work in place of reference counting.

shared_ptr class actually does internal reference counting, but it
does it in a thread-safe way (using CPU-atomic operations and volatile
variables). But then the problem is that the referenced class does not
have any knowledge of the reference count, which is handled one level
up, in the shared_ptr class. At the moment, I'm investigating a way to
solve the problem, using enable_shared_from_this class or weak_ptr
class.

>
> | I've
> | considered to change return type octave_base_value::subsasgn to void
> | (any implementation is supposed to return itself anyway), but I think
> | that'll break the octave_class code. So if anybody (probably jwe?)
> | could give me a hand on this one, I'd really appreciate.
>
> It would probably help me understand how this should work if you could
> post the changes for one of the classes that you have already
> converted.  The Array class would probably be a good one to start
> with.

Here's the diff for the Array class. Obviously, I didn't test those
changes yet, as I didn't finish the changes (I still need to convert
octave_value/octave_base_value, which I think is the core of the
crashes I have in QtHandles). However, the changes compile fine on
MSVC (and I assume they would also be fine under GCC).

Michael.

Attachment: Array.diff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]