comparison base/ById.cpp @ 1729:abd8b9673028 by-id

Experiment toward working out an id-model store
author Chris Cannam
date Thu, 20 Jun 2019 14:57:39 +0100
parents
children
comparison
equal deleted inserted replaced
1727:8efce64dd85e 1729:abd8b9673028
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13 */
14
15 #include "ById.h"
16
17 #include <QMutex>
18
19 #include <climits>
20
21 int
22 WithId::getNextId()
23 {
24 static int nextId = 0;
25 static QMutex mutex;
26 QMutexLocker locker(&mutex);
27 int i = nextId;
28 if (nextId == INT_MAX) {
29 nextId = INT_MIN;
30 }
31 ++nextId;
32 return i;
33 }