https://bugs.freedesktop.org/show_bug.cgi?id=62525

          Priority: medium
            Bug ID: 62525
          Assignee: [email protected]
           Summary: Convert manual refcounting / copy-on-write
                    implementations to cow_wrapper
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: [email protected]
          Hardware: Other
            Status: UNCONFIRMED
           Version: unspecified
         Component: Libreoffice
           Product: LibreOffice

This is a medium-level EasyHack, and can be split up nicely into converting
individual classes one after another. If you work on one class, or one set of
classes inside a subsystem, please add a line to this bug stating so.

What is this about
==================

The LibreOffice codebase, at a number of occasions, employs the CopyOnWrite
pattern to make passing big objects around by-value acceptably cheap, see this
article for some more background:

http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Copy-on-write

Currently we have quite a number of ad-hoc implementations of that pattern,
with a number of known problems (getting it wrong in corner cases, different
refcount semantics (is zero refcount good for deletion? does it mean one client
left?), and a (hopefully generic) helper template for easy conversion of
already-pimpled classes:
http://cgit.freedesktop.org/libreoffice/core/tree/o3tl/inc/o3tl/cow_wrapper.hxx

The task at hand is to convert as many of those sprawling ad-hoc
implementations over to cow_wrapper

What this is not about
======================

This is not about whether COW is a useful pattern in the first place - we want
to consolidate the code here to avoid nasty corner cases. If you want to go for
a tangential read on that, this one is nice: http://www.gotw.ca/gotw/045.htm

Also note that cow_wrapper defaults to non-threadsafe mode (mimicking std
behaviour in LibO code, the application being inherently single-threaded
anyway).

Details
=======

If you want to find a victim, go grep the source tree for .hxx files containing
nRefCount (there are variations in that name, but the aforementioned one should
already give enough hits for the while).

If the code looks like implementing pimpl idiom
(http://www.gotw.ca/gotw/024.htm) and Copy-on-write semantics, try wedging it
into using cow_wrapper instead.

Example conversion from back in the day:

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b6368dd527fd7ebe307cebe5c2275983df9ee851

and 

http://cgit.freedesktop.org/libreoffice/core/commit/?id=776b7235e23735189dbeafa6de93a4a2eaa2bf30

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to