Re: Deprecation of QSharedMemory and QSystemSemaphore

2023-12-01 Thread Méven
I thought about using QSharedMemory in previewjob / thumbnail ioworker to
allow shared memory across OS aka better thumbnails on windows.

Answers in the mail show the alternative but will require a bunch of
tinkering.

Q: I still need shared memory, what can I use instead?
A: Use QFile::map(). A memory-mapped file without the QFile::MapPrivateOption
is shared memory.
Seehttps://doc.qt.io/qt-6/shared-memory.html#sharing-memory-via-memory-mapped-files

Files are well-understood and common across all OSes, which should also make
reviewing code for problems and race conditions much simpler.

For example, using QTemporaryFile and renaming, you can prepare the shared
memory area before committing it to visibility to other processes.


Q: I need an equivalent of QSystemSemaphore, what can I use instead?
A: Use QFile::map() and put an atomic or a PThread locking primitive there.
Alternatively, use QLockFile.



Le ven. 1 déc. 2023 à 15:50, Thiago Macieira  a écrit :

> On Friday, 1 December 2023 14:01:14 CET Kai Uwe Broulik wrote:
> > QSystemSemaphore:
> > * Solid optical disc handling
> > * Digikam server starter
> >
> > QSharedMemory:
> > * Marble
> > * KMemFile used by KSycoca
> > * Solid again
> > * Snorenotify
> > * Amarok
> > * Kdenlive
> >
> > At a glance it looks like some (e.g. Solid) can probably use QLockFile
> > or are Linux-specific and can use memfd
> >
> > Qt folks are aware of QtSingleApplication but we couldn’t really speak
> > of the other use cases, in particular KSycoca.
>
> KSycoca is supposed to be real sharing of memory.
>
> For the other ones, the question is what they're using QSharedMemory for
> (how
> many processes, what's the ownership model).
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>Software Architect - Intel DCAI Cloud Engineering
>
>
>
>

-- 
Méven


Re: Deprecation of QSharedMemory and QSystemSemaphore

2023-12-01 Thread Thiago Macieira
On Friday, 1 December 2023 14:01:14 CET Kai Uwe Broulik wrote:
> QSystemSemaphore:
> * Solid optical disc handling
> * Digikam server starter
> 
> QSharedMemory:
> * Marble
> * KMemFile used by KSycoca
> * Solid again
> * Snorenotify
> * Amarok
> * Kdenlive
> 
> At a glance it looks like some (e.g. Solid) can probably use QLockFile
> or are Linux-specific and can use memfd
> 
> Qt folks are aware of QtSingleApplication but we couldn’t really speak
> of the other use cases, in particular KSycoca.

KSycoca is supposed to be real sharing of memory.

For the other ones, the question is what they're using QSharedMemory for (how 
many processes, what's the ownership model).

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering





Deprecation of QSharedMemory and QSystemSemaphore

2023-12-01 Thread Kai Uwe Broulik

Hi everyone,

at Qt Contributor’s Summit it came up that 
QSharedMemory/QSystemSemaphore are fundamentally broken and will be 
binned. [1]


I found that we have a few users of those classes according to lxc:

QSystemSemaphore:
* Solid optical disc handling
* Digikam server starter

QSharedMemory:
* Marble
* KMemFile used by KSycoca
* Solid again
* Snorenotify
* Amarok
* Kdenlive

At a glance it looks like some (e.g. Solid) can probably use QLockFile 
or are Linux-specific and can use memfd


Qt folks are aware of QtSingleApplication but we couldn’t really speak 
of the other use cases, in particular KSycoca.


Cheers
Kai Uwe

[1] 
https://lists.qt-project.org/pipermail/development/2023-November/044680.html