Results 1 to 5 of 5

Thread: QSharedData - implicit sharing

  1. #1
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QSharedData - implicit sharing

    Hi all!...I need an advise...as usual
    I want to use QShareData...
    I create my class "DataStorage" let's say...and it contains a QSharedDataPointer<data_type> to some data that I need to be referenced in different threads let's say.
    So now...when I want the implicit sharing of referenced data make work...When I reference ...should I create only the references of QSharedDataPointer<data_type> or references of QSharedData class that contains this DataPointer to make the implicit sharing work ?
    I mean when I send this data using signal...should I use reference to QSharedData inheriting class or just reference to QSharedDataPointer<data_type> of this class ?
    Thanks a LOT!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSharedData - implicit sharing

    QSharedData is meant to be used together with QSharedDataPointer.
    See this example: http://doc.trolltech.com/4.3/qshared...r.html#details.

    If you want it to work you should always use the QSharedData subclass, not the shared data pointer directly.

  3. #3
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSharedData - implicit sharing

    I know...I have implemented my code as it is shown in example you passed me...
    What I was asking is HOW CAN I USE NOW IMPLEMENTED CLASSES TO SEND A DATA OVER SIGNAL AND MAKE REFERENCE COUNT WORKING ...
    SHOULD I USE INHERITING QSHAREDATA CLASS CONTAING QSHAREDDATAPOINTER OR CAN I JUST SEND REFERENCE TO THIS POINTER TO MAKE REFERENCE COUNT WORKING ?
    I THINK IT IS PRETTY CLEAR WHAT I WAS ASKING....
    tHANKS

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSharedData - implicit sharing

    Well, the usage is obvious from the documentation, so I can't see what you can't understand.

    Across signals and slots you should pass instances of your equivalent of the Employee class.
    Maybe you can post the code, if this doesn't help you.

  5. #5
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSharedData - implicit sharing

    Thanks
    that's what I needed to hear ...

Similar Threads

  1. Implicit sharing vs. c++ refereces
    By IrYoKu in forum Qt Programming
    Replies: 12
    Last Post: 9th November 2011, 23:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.