Arcane  v3.16.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
Mutex.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Mutex.cc (C) 2000-2025 */
9/* */
10/* Mutex pour le multi-threading. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/concurrency/Mutex.h"
15#include "arccore/concurrency/IThreadImplementation.h"
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20namespace Arcane
21{
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26Mutex::
27Mutex()
28{
29 m_thread_impl = Concurrency::getThreadImplementation();
30 m_p = m_thread_impl->createMutex();
31}
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36Mutex::
37~Mutex()
38{
39 m_thread_impl->destroyMutex(m_p);
40}
41
42void Mutex::
43lock()
44{
45 m_thread_impl->lockMutex(m_p);
46}
47
48void Mutex::
49unlock()
50{
51 m_thread_impl->unlockMutex(m_p);
52}
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57MutexImpl* GlobalMutex::m_p = 0;
58
60init(MutexImpl* p)
61{
62 m_p = p;
63}
64
65void GlobalMutex::
66destroy()
67{
68 m_p = 0;
69}
70
71void GlobalMutex::
72lock()
73{
74 if (m_p)
75 Concurrency::getThreadImplementation()->lockMutex(m_p);
76}
77
78void GlobalMutex::
79unlock()
80{
81 if (m_p)
82 Concurrency::getThreadImplementation()->unlockMutex(m_p);
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88} // End namespace Arccore
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
static void init(MutexImpl *p)
Initialise le mutex global. Interne a Arccore. Doit être alloué par new.
Definition Mutex.cc:60
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-