Add option 'Show complete log'
[TortoiseGit.git] / src / TortoiseMerge / libsvn_diff / mutex.c
blob3663f5b15cf689a536a2b49ffd5f15e0ca752eea
1 /*
2 * svn_mutex.c: routines for mutual exclusion.
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 * ====================================================================
24 #include "svn_private_config.h"
25 #include "private/svn_mutex.h"
27 svn_error_t *
28 svn_mutex__init(svn_mutex__t **mutex_p,
29 svn_boolean_t mutex_required,
30 apr_pool_t *result_pool)
32 /* always initialize the mutex pointer, even though it is not
33 strictly necessary if APR_HAS_THREADS has not been set */
34 *mutex_p = NULL;
36 #if APR_HAS_THREADS
37 if (mutex_required)
39 apr_thread_mutex_t *apr_mutex;
40 apr_status_t status =
41 apr_thread_mutex_create(&apr_mutex,
42 APR_THREAD_MUTEX_DEFAULT,
43 result_pool);
44 if (status)
45 return svn_error_wrap_apr(status, _("Can't create mutex"));
47 *mutex_p = apr_mutex;
49 #endif
51 return SVN_NO_ERROR;
54 svn_error_t *
55 svn_mutex__lock(svn_mutex__t *mutex)
57 #if APR_HAS_THREADS
58 if (mutex)
60 apr_status_t status = apr_thread_mutex_lock(mutex);
61 if (status)
62 return svn_error_wrap_apr(status, _("Can't lock mutex"));
64 #endif
66 return SVN_NO_ERROR;
69 svn_error_t *
70 svn_mutex__unlock(svn_mutex__t *mutex,
71 svn_error_t *err)
73 #if APR_HAS_THREADS
74 if (mutex)
76 apr_status_t status = apr_thread_mutex_unlock(mutex);
77 if (status && !err)
78 return svn_error_wrap_apr(status, _("Can't unlock mutex"));
80 #endif
82 return err;