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