1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : data_short_port_provides.cxx
24 // Author : André RIBES (EDF)
27 #include "data_short_port_provides.hxx"
29 data_short_port_provides::data_short_port_provides() {
31 short_termine = false;
32 short_mutex = new pthread_mutex_t();
33 pthread_mutex_init(short_mutex, NULL);
34 short_condition = new pthread_cond_t();
35 pthread_cond_init(short_condition, NULL);
36 short_termine_cp = true;
37 short_mutex_cp = new pthread_mutex_t();
38 pthread_mutex_init(short_mutex_cp, NULL);
39 short_condition_cp = new pthread_cond_t();
40 pthread_cond_init(short_condition_cp, NULL);
43 data_short_port_provides::~data_short_port_provides() {
44 pthread_mutex_destroy(short_mutex);
46 pthread_cond_destroy(short_condition);
47 delete short_condition;
48 pthread_mutex_destroy(short_mutex_cp);
49 delete short_mutex_cp;
50 pthread_cond_destroy(short_condition_cp);
51 delete short_condition_cp;
55 data_short_port_provides::put(CORBA::Short data) {
56 // On attend que le get soit fait
57 pthread_mutex_lock(short_mutex_cp);
58 while (short_termine_cp == false)
60 pthread_cond_wait(short_condition_cp, short_mutex_cp);
62 short_termine_cp = false;
63 pthread_mutex_unlock(short_mutex_cp);
65 pthread_mutex_lock(short_mutex);
68 pthread_cond_signal(short_condition);
69 pthread_mutex_unlock(short_mutex);
73 data_short_port_provides::get() {
75 pthread_mutex_lock(short_mutex);
76 while (short_termine == false)
78 pthread_cond_wait(short_condition, short_mutex);
81 short_termine = false;
82 pthread_mutex_unlock(short_mutex);
84 // On indique que l'on a copie la valeur
85 pthread_mutex_lock(short_mutex_cp);
86 short_termine_cp = true;
87 pthread_cond_signal(short_condition_cp);
88 pthread_mutex_unlock(short_mutex_cp);
93 data_short_port_provides::get_port_ref() {