Revision: 73084
http://sourceforge.net/p/brlcad/code/73084
Author: brlcad
Date: 2019-05-17 13:48:11 +0000 (Fri, 17 May 2019)
Log Message:
-----------
apply header, footer, and update ws indent
Modified Paths:
--------------
brlcad/trunk/src/libbu/semaphore_register.cpp
Modified: brlcad/trunk/src/libbu/semaphore_register.cpp
===================================================================
--- brlcad/trunk/src/libbu/semaphore_register.cpp 2019-05-17 13:47:33 UTC
(rev 73083)
+++ brlcad/trunk/src/libbu/semaphore_register.cpp 2019-05-17 13:48:11 UTC
(rev 73084)
@@ -1,3 +1,23 @@
+/* S E M A P H O R E _ R E G I S T E R . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2019 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
#include "common.h"
#include <vector>
@@ -16,22 +36,22 @@
static std::vector<const char *> &
semaphore_registry(bool wipe = false)
{
- /* semaphore #1 is used internally here and only here, so we start with it */
- static std::vector<const char *> semaphores = {"SEM_LOCK"};
+ /* semaphore #1 is used internally here and only here, so we start with it
*/
+ static std::vector<const char *> semaphores = {"SEM_LOCK"};
- if (wipe) {
+ if (wipe) {
#ifdef DEBUGSEM
- std::cout << "!!! clearing " << semaphores.size() << " semaphores" <<
std::endl;
- for (size_t i = 0; i < semaphores.size(); i++) {
- std::cout << "!!! found " << semaphores[i] << " = " << i+1 << std::endl;
+ std::cout << "!!! clearing " << semaphores.size() << " semaphores" <<
std::endl;
+ for (size_t i = 0; i < semaphores.size(); i++) {
+ std::cout << "!!! found " << semaphores[i] << " = " << i+1 <<
std::endl;
+ }
+#endif
+ bu_semaphore_acquire(SEM_LOCK);
+ semaphores.clear();
+ bu_semaphore_release(SEM_LOCK);
}
-#endif
- bu_semaphore_acquire(SEM_LOCK);
- semaphores.clear();
- bu_semaphore_release(SEM_LOCK);
- }
- return semaphores;
+ return semaphores;
}
@@ -38,7 +58,7 @@
extern "C" void
semaphore_clear(void)
{
- (void)semaphore_registry(true);
+ (void)semaphore_registry(true);
}
@@ -45,17 +65,17 @@
static size_t
semaphore_registered(const char *name)
{
- const std::vector<const char *> &semaphores = semaphore_registry();
+ const std::vector<const char *> &semaphores = semaphore_registry();
- for (size_t i = 0; i < semaphores.size(); ++i) {
- if (BU_STR_EQUAL(semaphores[i], name)) {
+ for (size_t i = 0; i < semaphores.size(); ++i) {
+ if (BU_STR_EQUAL(semaphores[i], name)) {
#ifdef DEBUGSEM
- printf("!!! found %s = %zu\n", semaphores[i], i+1);
+ printf("!!! found %s = %zu\n", semaphores[i], i+1);
#endif
- return i+1;
+ return i+1;
+ }
}
- }
- return 0;
+ return 0;
}
@@ -62,24 +82,33 @@
extern "C" int
bu_semaphore_register(const char *name)
{
- std::vector<const char *> &semaphores = semaphore_registry();
+ std::vector<const char *> &semaphores = semaphore_registry();
#ifdef DEBUGSEM
- printf("!!! registering %s (have %zu)\n", name, semaphores.size());
+ printf("!!! registering %s (have %zu)\n", name, semaphores.size());
#endif
- bu_semaphore_acquire(SEM_LOCK);
- size_t idx = semaphore_registered(name);
- if (!idx) {
- semaphores.push_back(name);
- idx = semaphores.size();
- }
- bu_semaphore_release(SEM_LOCK);
+ bu_semaphore_acquire(SEM_LOCK);
+ size_t idx = semaphore_registered(name);
+ if (!idx) {
+ semaphores.push_back(name);
+ idx = semaphores.size();
+ }
+ bu_semaphore_release(SEM_LOCK);
#ifdef DEBUGSEM
- printf("!!! added %s = %zu\n", name, idx);
+ printf("!!! added %s = %zu\n", name, idx);
#endif
- return idx;
+ return idx;
}
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits