[mapguide-commits] r1045 - trunk/MgDev/Common/CoordinateSystem
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jan 12 18:11:18 EST 2007
Author: brucedechant
Date: 2007-01-12 18:11:18 -0500 (Fri, 12 Jan 2007)
New Revision: 1045
Modified:
trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp
trunk/MgDev/Common/CoordinateSystem/CriticalSection.h
Log:
Add critical sections around coordinate system APIs.
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp 2007-01-12 23:10:54 UTC (rev 1044)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp 2007-01-12 23:11:18 UTC (rev 1045)
@@ -48,14 +48,19 @@
}
~CInitCPL()
{
- // free PROJ4 resources
- pj_deallocate_grids();
+ {
+ // Lock all threads
+ AutoCriticalClass acc;
- // free CPL resources
- CSVDeaccess(NULL);
- CPLFinderClean();
- CPLCleanupTLS();
+ // free PROJ4 resources
+ pj_deallocate_grids();
+ // free CPL resources
+ CSVDeaccess(NULL);
+ CPLFinderClean();
+ CPLCleanupTLS();
+ }
+
// free CoordinateSystem resources
CCoordinateSystem::DeleteCatalog();
}
@@ -232,6 +237,9 @@
///</summary>
CCoordinateSystem::CCoordinateSystem(CREFSTRING ogcWkt)
{
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
m_latLonSrs = NULL;
@@ -691,6 +699,9 @@
x = 0.0;
y = 0.0;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Check to see if the conversion is allowed, if not throw an exception
@@ -741,6 +752,9 @@
///</returns>
void CCoordinateSystem::ConvertFromLonLat(double lon[], double lat[], double x[], double y[], int arraySize)
{
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
double dCoords[3] = { 0.0, 0.0, 0.0 };
@@ -802,6 +816,9 @@
lat = 0.0;
lon = 0.0;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Check to see if the conversion is allowed, if not throw an exception
@@ -852,6 +869,9 @@
///</returns>
void CCoordinateSystem::ConvertToLonLat(double x[], double y[], double lon[], double lat[], int arraySize)
{
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
double dCoords[3] = { 0.0, 0.0, 0.0 };
@@ -1024,6 +1044,9 @@
throw new CInvalidCoordinateSystemTypeException(L"CCoordinateSystem.MeasureGreatCircleDistance", __LINE__, __WFILE__, L"MeasureGreatCircleDistance does not work with Arbitrary coordinate systems.");
}
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Calculate Great Circle distance using the following formula:
@@ -1127,6 +1150,9 @@
{
double azimuth = 0.0;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
if(m_coordinateSystemType == CCoordinateSystemType::Arbitrary)
@@ -1250,6 +1276,9 @@
x = 0.0;
y = 0.0;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
if(m_coordinateSystemType == CCoordinateSystemType::Arbitrary)
@@ -1364,6 +1393,9 @@
char* proj4 = NULL;
wchar_t* csProj4 = NULL;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Initialize the catalog cache if it has not been created yet
@@ -1524,6 +1556,9 @@
wchar_t* csWkt = NULL;
char* wkt = NULL;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Initialize the catalog cache if it has not been created yet
@@ -1965,7 +2000,8 @@
if(m_catalog == NULL )
{
// Lock all threads while we create the catalog
- CriticalClass.Enter();
+ AutoCriticalClass acc;
+
// We have to check for NULL again because we might have been locked out by another
// thread that just finished initializing the catalog.
if(m_catalog == NULL )
@@ -1973,7 +2009,6 @@
// Create the catalog. We only want to do this once!
m_catalog = new CCoordinateSystemCatalog();
}
- CriticalClass.Leave();
// Throw exception if we failed to initialize the catalog
if (m_catalog == NULL)
@@ -1989,12 +2024,10 @@
if (m_catalog != NULL)
{
// Lock all threads while we delete the catalog
- CriticalClass.Enter();
+ AutoCriticalClass acc;
delete m_catalog;
m_catalog = NULL;
-
- CriticalClass.Leave();
}
}
@@ -2019,6 +2052,9 @@
OGRErr error = OGRERR_NONE;
char* epsgWkt = NULL;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Initialize the catalog cache if it has not been created yet
@@ -2117,6 +2153,9 @@
long code;
OGRErr error = OGRERR_NONE;
+ // Lock all threads
+ AutoCriticalClass acc;
+
try
{
// Initialize the catalog cache if it has not been created yet
Modified: trunk/MgDev/Common/CoordinateSystem/CriticalSection.h
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CriticalSection.h 2007-01-12 23:10:54 UTC (rev 1044)
+++ trunk/MgDev/Common/CoordinateSystem/CriticalSection.h 2007-01-12 23:11:18 UTC (rev 1045)
@@ -109,4 +109,19 @@
// This is used to protect library calls
static CustomCriticalSection CriticalClass;
+class AutoCriticalClass
+{
+public:
+
+ AutoCriticalClass()
+ {
+ CriticalClass.Enter();
+ }
+
+ ~AutoCriticalClass()
+ {
+ CriticalClass.Leave();
+ }
+};
+
#endif
More information about the mapguide-commits
mailing list