[esnacc-dev] [PATCH 1/2] cxx-lib: remove vdathread support

Aaron Conole aconole at bytheb.org
Thu Mar 16 21:04:00 UTC 2017


VDAThreads was an unused and psuedo-proprietary method for coordinating
multiple threads to share access to memory and buffers.  After
discussion with Pierce Leonberger of BAE Systems, I don't see a need to
continue supporting it.  Modern environments offer thread support, and such
support is baked into the languages (c++11, c11, etc).  Even if it weren't
there is no reason for eSNACC to provide it.

Signed-off-by: Aaron Conole <aconole at bytheb.org>
---
 cxx-lib/automake.mk          |  1 -
 cxx-lib/inc/asn-incl.h       |  3 --
 cxx-lib/src/asn-any.cpp      |  4 --
 cxx-lib/src/vda_threads2.cpp | 94 --------------------------------------------
 4 files changed, 102 deletions(-)
 delete mode 100644 cxx-lib/src/vda_threads2.cpp

diff --git a/cxx-lib/automake.mk b/cxx-lib/automake.mk
index 126c54d..9d343b5 100644
--- a/cxx-lib/automake.mk
+++ b/cxx-lib/automake.mk
@@ -42,7 +42,6 @@ cxx_lib_libcxxasn1_la_SOURCES = \
 	cxx-lib/src/hash.cpp \
 	cxx-lib/src/meta.cpp \
 	cxx-lib/src/asn-octs.cpp \
-	cxx-lib/src/vda_threads2.cpp \
 	cxx-lib/src/print.cpp \
 	cxx-lib/src/tcl-if.cpp \
 	cxx-lib/src/asn-bits.cpp \
diff --git a/cxx-lib/inc/asn-incl.h b/cxx-lib/inc/asn-incl.h
index 9508bdd..ca493d8 100644
--- a/cxx-lib/inc/asn-incl.h
+++ b/cxx-lib/inc/asn-incl.h
@@ -1428,9 +1428,6 @@ public:
 };
 
 
-void SNACCDLL_API threadLock();
-void SNACCDLL_API threadUnlock();
-void SNACCDLL_API threadDestroy();
 extern "C" {
 void SNACCDLL_API SNACC_CleanupMemory();
 }
diff --git a/cxx-lib/src/asn-any.cpp b/cxx-lib/src/asn-any.cpp
index c06adf6..d04da48 100644
--- a/cxx-lib/src/asn-any.cpp
+++ b/cxx-lib/src/asn-any.cpp
@@ -589,10 +589,6 @@ AsnAny &AsnAny::operator = (const AsnAny &o)
 extern "C" {
 void SNACCDLL_API SNACC_CleanupMemory()
 {
-#ifndef NO_THREADS
-   threadDestroy();  // ONLY necessary if a thread lock is created (and it is 
-                     //  important to clear all memory leaks before exiting.
-#endif
    AsnAny::AsnAnyDestroyHashTbls();   // FINAL call, to clear static tables, 
                                       //  before exiting.
 }
diff --git a/cxx-lib/src/vda_threads2.cpp b/cxx-lib/src/vda_threads2.cpp
deleted file mode 100644
index 314636d..0000000
--- a/cxx-lib/src/vda_threads2.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-
-// The following "SM_NO_THREADS" define allows the application/lib code that 
-//  uses threads to not require this define (cleaner).  In this source module
-//  the thread lock logic is disabled (there is some slight performance loss
-//  in the wasted no-op call to the thread lock/unlock, but the logic is
-//  cleaner).  This technique also has the advantage that only this source
-//  file needs the "SM_NO_THREADS" definition to turn thread locking off.
-
-#include "asn-incl.h"
-
-_BEGIN_SNACC_NAMESPACE
-
-#ifdef NO_THREADS
-
-void threadDestroy()
-{
-}
-void threadLock()
-{
-}
-void threadUnlock()
-{
-}
-
-#else
-
-#ifdef WIN32
-
-#include <windows.h>
-HANDLE gMutex;
-
-#else 
-
-#include <pthread.h>
-pthread_mutex_t gMutex;
-
-#endif
-
-
-
-#ifndef WIN32
-void initMutex(void)
-{
-  pthread_mutex_init(&gMutex, NULL);
-}
-#endif
-
-//
-//
-void threadDestroy()
-{
-#ifdef WIN32
-   CloseHandle(gMutex);
-#else
-   pthread_mutex_destroy(&gMutex);
-#endif
-}
-
-//
-//
-void threadLock()
-{
-#ifdef WIN32
-
-   gMutex = CreateMutex(NULL, false, "Win32_Mutex");
-   WaitForSingleObject(gMutex, INFINITE);
-
-#else //UNIX
-
-#ifdef SUNOS
-    pthread_once_t once_block = {PTHREAD_ONCE_INIT};
-#else
-    pthread_once_t once_block = PTHREAD_ONCE_INIT;
-#endif
-
-    pthread_once(&once_block, initMutex);
-
-    pthread_mutex_lock(&gMutex);
-#endif  //WIN32
-}
-
-void threadUnlock()
-{
-#ifdef WIN32
-    ReleaseMutex(gMutex);
-#else   //UNIX
-    pthread_mutex_unlock(&gMutex);
-#endif  //WIN32
-}
-
-
-#endif
-_END_SNACC_NAMESPACE
-// EOF vda_threads2.cpp
-- 
2.9.3




More information about the dev mailing list