Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
e18ec024
Commit
e18ec024
authored
5 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Replaced pthread mutex by std::mutex.
parent
fd1c4b15
No related branches found
Branches containing commit
Tags
cdo-1.9.4
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cdi_lockedIO.cc
+1
-3
1 addition, 3 deletions
src/cdi_lockedIO.cc
src/convert_units.cc
+9
-34
9 additions, 34 deletions
src/convert_units.cc
with
10 additions
and
37 deletions
src/cdi_lockedIO.cc
+
1
−
3
View file @
e18ec024
...
...
@@ -88,10 +88,8 @@ streamInqVlistLocked(int p_fileID)
{
if
(
Threading
::
cdoLockIO
)
PTHREAD_MUTEX_LOCK
(
&
streamMutex
);
int
vlistID
=
streamInqVlist
(
p_fileID
);
if
(
Threading
::
cdoLockIO
)
PTHREAD_MUTEX_UNLOCK
(
&
streamMutex
);
#ifdef HAVE_LIBPTHREAD
if
(
Threading
::
cdoLockIO
)
pthread_mutex_unlock
(
&
streamMutex
);
#endif
return
vlistID
;
}
...
...
This diff is collapsed.
Click to expand it.
src/convert_units.cc
+
9
−
34
View file @
e18ec024
...
...
@@ -25,46 +25,23 @@
#ifdef HAVE_UDUNITS2
static
void
udunitsInitialize
(
void
);
#ifdef HAVE_LIBPTHREAD
#include
<pthread.h>
static
pthread_once_t
udunitsInitThread
=
PTHREAD_ONCE_INIT
;
static
pthread_mutex_t
udunitsMutex
=
PTHREAD_MUTEX_INITIALIZER
;
#
define UDUNITS_LOCK() pthread_mutex_lock(&udunitsM
utex
)
#define UDUNITS_UNLOCK() pthread_mutex_unlock(&
udunitsMutex
)
#define UDUNITS_
INIT() pthread_once(&udunitsInitThread, udunitsInitialize)
#
include
<m
utex
>
static
std
::
mutex
udunitsMutex
;
#define UDUNITS_
LOCK() std::unique_lock<std::mutex> locked_mutex(udunitsMutex);
#else
static
bool
udunitsInit
=
false
;
#define UDUNITS_LOCK()
#define UDUNITS_UNLOCK()
#define UDUNITS_INIT() \
if (!udunitsInit) udunitsInitialize();
#endif
static
ut_system
*
ut_read
=
nullptr
;
static
void
udunitsInitialize
(
void
)
{
#ifdef HAVE_LIBPTHREAD
/* initialize global API mutex lock */
pthread_mutex_init
(
&
udunitsMutex
,
nullptr
);
#else
udunitsInit
=
true
;
#endif
}
static
void
*
get_converter
(
char
*
src_unit_str
,
char
*
tgt_unit_str
,
int
*
rstatus
)
{
ut_unit
*
src_unit
,
*
tgt_unit
;
cv_converter
*
ut_units_converter
=
nullptr
;
int
status
;
...
...
@@ -94,7 +71,7 @@ get_converter(char *src_unit_str, char *tgt_unit_str, int *rstatus)
}
ut_trim
(
src_unit_str
,
UT_ASCII
);
src_unit
=
ut_parse
(
ut_read
,
src_unit_str
,
UT_ASCII
);
ut_unit
*
src_unit
=
ut_parse
(
ut_read
,
src_unit_str
,
UT_ASCII
);
if
(
ut_get_status
()
!=
UT_SUCCESS
)
{
if
(
Options
::
cdoVerbose
)
cdoWarning
(
"Udunits: Error parsing units: [%s]"
,
src_unit_str
);
...
...
@@ -102,7 +79,7 @@ get_converter(char *src_unit_str, char *tgt_unit_str, int *rstatus)
}
ut_trim
(
tgt_unit_str
,
UT_ASCII
);
tgt_unit
=
ut_parse
(
ut_read
,
tgt_unit_str
,
UT_ASCII
);
ut_unit
*
tgt_unit
=
ut_parse
(
ut_read
,
tgt_unit_str
,
UT_ASCII
);
if
(
ut_get_status
()
!=
UT_SUCCESS
)
{
if
(
Options
::
cdoVerbose
)
cdoWarning
(
"Udunits: Error parsing units: [%s]"
,
tgt_unit_str
);
...
...
@@ -151,7 +128,6 @@ cdoConvertFree(void *ut_converter)
{
UDUNITS_LOCK
();
cv_free
((
cv_converter
*
)
ut_converter
);
UDUNITS_UNLOCK
();
}
void
...
...
@@ -162,7 +138,6 @@ cdoConvertDestroy()
UDUNITS_LOCK
();
ut_free_system
(
ut_read
);
ut_read
=
nullptr
;
UDUNITS_UNLOCK
();
}
}
#endif
...
...
@@ -174,10 +149,10 @@ cdoConvertUnits(void **ut_converter, bool *changeunits, char *units, char *units
{
#ifdef HAVE_UDUNITS2
int
status
;
UDUNITS_INIT
();
UDUNITS_LOCK
();
*
ut_converter
=
get_converter
(
units_old
,
units
,
&
status
);
UDUNITS_UNLOCK
();
{
UDUNITS_LOCK
();
*
ut_converter
=
get_converter
(
units_old
,
units
,
&
status
);
}
if
(
*
ut_converter
==
nullptr
)
{
if
(
status
==
-
2
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment