annotate 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
rev   line source
Chris@1729 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1729 2
Chris@1729 3 /*
Chris@1729 4 Sonic Visualiser
Chris@1729 5 An audio file viewer and annotation editor.
Chris@1729 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1729 7
Chris@1729 8 This program is free software; you can redistribute it and/or
Chris@1729 9 modify it under the terms of the GNU General Public License as
Chris@1729 10 published by the Free Software Foundation; either version 2 of the
Chris@1729 11 License, or (at your option) any later version. See the file
Chris@1729 12 COPYING included with this distribution for more information.
Chris@1729 13 */
Chris@1729 14
Chris@1729 15 #include "ById.h"
Chris@1729 16
Chris@1729 17 #include <QMutex>
Chris@1729 18
Chris@1729 19 #include <climits>
Chris@1729 20
Chris@1729 21 int
Chris@1729 22 WithId::getNextId()
Chris@1729 23 {
Chris@1729 24 static int nextId = 0;
Chris@1729 25 static QMutex mutex;
Chris@1729 26 QMutexLocker locker(&mutex);
Chris@1729 27 int i = nextId;
Chris@1729 28 if (nextId == INT_MAX) {
Chris@1729 29 nextId = INT_MIN;
Chris@1729 30 }
Chris@1729 31 ++nextId;
Chris@1729 32 return i;
Chris@1729 33 }