Showing the changes to codec/processing/src/common/thread.cpp (1 of 124 files). Show all
Unified · Split
| @@ -0,0 +1,93 @@ | ||
| 1 | +/*! | |
| 2 | + * \copy | |
| 3 | + * Copyright (c) 2009-2013, Cisco Systems | |
| 4 | + * All rights reserved. | |
| 5 | + * | |
| 6 | + * Redistribution and use in source and binary forms, with or without | |
| 7 | + * modification, are permitted provided that the following conditions | |
| 8 | + * are met: | |
| 9 | + * | |
| 10 | + * * Redistributions of source code must retain the above copyright | |
| 11 | + * notice, this list of conditions and the following disclaimer. | |
| 12 | + * | |
| 13 | + * * Redistributions in binary form must reproduce the above copyright | |
| 14 | + * notice, this list of conditions and the following disclaimer in | |
| 15 | + * the documentation and/or other materials provided with the | |
| 16 | + * distribution. | |
| 17 | + * | |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 21 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 22 | + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 23 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 24 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 25 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 26 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 27 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 28 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 29 | + * POSSIBILITY OF SUCH DAMAGE. | |
| 30 | + * | |
| 31 | + * \file thread.cpp | |
| 32 | + * | |
| 33 | + * \brief Interfaces introduced in thread programming | |
| 34 | + * | |
| 35 | + * \date 11/17/2009 Created | |
| 36 | + * | |
| 37 | + ************************************************************************************* | |
| 38 | + */ | |
| 39 | + | |
| 40 | +#include "thread.h" | |
| 41 | + | |
| 42 | +WELSVP_NAMESPACE_BEGIN | |
| 43 | + | |
| 44 | +#if defined(_WIN32) | |
| 45 | + | |
| 46 | +WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) { | |
| 47 | + InitializeCriticalSection (mutex); | |
| 48 | + | |
| 49 | + return WELS_THREAD_ERROR_OK; | |
| 50 | +} | |
| 51 | + | |
| 52 | +WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) { | |
| 53 | + EnterCriticalSection (mutex); | |
| 54 | + | |
| 55 | + return WELS_THREAD_ERROR_OK; | |
| 56 | +} | |
| 57 | + | |
| 58 | +WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) { | |
| 59 | + LeaveCriticalSection (mutex); | |
| 60 | + | |
| 61 | + return WELS_THREAD_ERROR_OK; | |
| 62 | +} | |
| 63 | + | |
| 64 | +WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) { | |
| 65 | + DeleteCriticalSection (mutex); | |
| 66 | + | |
| 67 | + return WELS_THREAD_ERROR_OK; | |
| 68 | +} | |
| 69 | + | |
| 70 | +#elif defined(__GNUC__) | |
| 71 | + | |
| 72 | +WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) { | |
| 73 | + return pthread_mutex_init (mutex, NULL); | |
| 74 | +} | |
| 75 | + | |
| 76 | +WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) { | |
| 77 | + return pthread_mutex_lock (mutex); | |
| 78 | +} | |
| 79 | + | |
| 80 | +WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) { | |
| 81 | + return pthread_mutex_unlock (mutex); | |
| 82 | +} | |
| 83 | + | |
| 84 | +WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) { | |
| 85 | + return pthread_mutex_destroy (mutex); | |
| 86 | +} | |
| 87 | + | |
| 88 | +#endif | |
| 89 | + | |
| 90 | +WELSVP_NAMESPACE_END | |
| 91 | + | |
| 92 | + | |
| 93 | + | |