X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fpbd%2Fid.cc;h=9a610c7418e4135f6980653375e4d42a40746642;hb=659701c59b76bdcbfcf5c1b8ce8962eb3f6a1ca2;hp=ab9c7e73929e158b11c978dc88933ca60445a6d5;hpb=0569107ddc0d2a8df6ca0a2c8cc16ebe8f3dee99;p=ardour.git diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc index ab9c7e7392..9a610c7418 100644 --- a/libs/pbd/id.cc +++ b/libs/pbd/id.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2000-2007 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ */ #include -#include #include #ifndef __STDC_FORMAT_MACROS @@ -32,19 +31,24 @@ using namespace std; using namespace PBD; -Glib::Mutex* ID::counter_lock = 0; +Glib::Threads::Mutex* ID::counter_lock = 0; uint64_t ID::_counter = 0; void ID::init () { - counter_lock = new Glib::Mutex; + if (!counter_lock) + counter_lock = new Glib::Threads::Mutex; } ID::ID () { - Glib::Mutex::Lock lm (*counter_lock); - _id = _counter++; + reset (); +} + +ID::ID (const ID& other) +{ + _id = other._id; } ID::ID (string str) @@ -52,6 +56,13 @@ ID::ID (string str) string_assign (str); } +void +ID::reset () +{ + Glib::Threads::Mutex::Lock lm (*counter_lock); + _id = _counter++; +} + int ID::string_assign (string str) { @@ -84,6 +95,15 @@ ID::operator= (string str) return *this; } +ID& +ID::operator= (const ID& other) +{ + if (&other != this) { + _id = other._id; + } + return *this; +} + ostream& operator<< (ostream& ostr, const ID& _id) {