Arcane  v3.14.10.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-2022 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-2012 */
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 Arccore
21{
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29Mutex::
30Mutex()
31{
32 m_thread_impl = Concurrency::getThreadImplementation();
33 m_p = m_thread_impl->createMutex();
34}
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39Mutex::
40~Mutex()
41{
42 m_thread_impl->destroyMutex(m_p);
43}
44
45void Mutex::
46lock()
47{
48 m_thread_impl->lockMutex(m_p);
49}
50
51void Mutex::
52unlock()
53{
54 m_thread_impl->unlockMutex(m_p);
55}
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60MutexImpl* GlobalMutex::m_p = 0;
61
63init(MutexImpl* p)
64{
65 m_p = p;
66}
67
68void GlobalMutex::
69destroy()
70{
71 m_p = 0;
72}
73
74void GlobalMutex::
75lock()
76{
77 if (m_p)
78 Concurrency::getThreadImplementation()->lockMutex(m_p);
79}
80
81void GlobalMutex::
82unlock()
83{
84 if (m_p)
85 Concurrency::getThreadImplementation()->unlockMutex(m_p);
86}
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
91} // End namespace Arccore
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
static void init(MutexImpl *p)
Initialise le mutex global. Interne a Arccore. Doit être alloué par new.
Definition Mutex.cc:63
Espace de nom de Arccore.
Definition ArcaneTypes.h:24