~ubuntu-branches/ubuntu/precise/jcsp/precise

« back to all changes in this revision

Viewing changes to src/org/jcsp/lang/Any2OneIntImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Landaeta
  • Date: 2010-06-20 18:12:26 UTC
  • Revision ID: james.westby@ubuntu.com-20100620181226-8yg8d9rjjjiuy7oz
Tags: upstream-1.1-rc4
ImportĀ upstreamĀ versionĀ 1.1-rc4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
    //////////////////////////////////////////////////////////////////////
 
2
    //                                                                  //
 
3
    //  JCSP ("CSP for Java") Libraries                                 //
 
4
    //  Copyright (C) 1996-2008 Peter Welch and Paul Austin.            //
 
5
    //                2001-2004 Quickstone Technologies Limited.        //
 
6
    //                                                                  //
 
7
    //  This library is free software; you can redistribute it and/or   //
 
8
    //  modify it under the terms of the GNU Lesser General Public      //
 
9
    //  License as published by the Free Software Foundation; either    //
 
10
    //  version 2.1 of the License, or (at your option) any later       //
 
11
    //  version.                                                        //
 
12
    //                                                                  //
 
13
    //  This library is distributed in the hope that it will be         //
 
14
    //  useful, but WITHOUT ANY WARRANTY; without even the implied      //
 
15
    //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR         //
 
16
    //  PURPOSE. See the GNU Lesser General Public License for more     //
 
17
    //  details.                                                        //
 
18
    //                                                                  //
 
19
    //  You should have received a copy of the GNU Lesser General       //
 
20
    //  Public License along with this library; if not, write to the    //
 
21
    //  Free Software Foundation, Inc., 59 Temple Place, Suite 330,     //
 
22
    //  Boston, MA 02111-1307, USA.                                     //
 
23
    //                                                                  //
 
24
    //  Author contact: P.H.Welch@kent.ac.uk                             //
 
25
    //                                                                  //
 
26
    //////////////////////////////////////////////////////////////////////
 
27
 
 
28
package org.jcsp.lang;
 
29
 
 
30
class Any2OneIntImpl implements ChannelInternalsInt, Any2OneChannelInt {
 
31
 
 
32
        private ChannelInternalsInt channel;
 
33
        private final Object writeMonitor = new Object();
 
34
        
 
35
        Any2OneIntImpl(ChannelInternalsInt _channel) {
 
36
                channel = _channel;
 
37
        }
 
38
 
 
39
        //Begin never used:
 
40
        public void endRead() {
 
41
                channel.endRead();
 
42
        }
 
43
 
 
44
        public int read() {
 
45
                return channel.read();
 
46
        }
 
47
 
 
48
        public boolean readerDisable() {
 
49
                return channel.readerDisable();
 
50
        }
 
51
 
 
52
        public boolean readerEnable(Alternative alt) {
 
53
                return channel.readerEnable(alt);
 
54
        }
 
55
 
 
56
        public boolean readerPending() {
 
57
                return channel.readerPending();
 
58
        }
 
59
 
 
60
        public void readerPoison(int strength) {
 
61
                channel.readerPoison(strength);
 
62
 
 
63
        }
 
64
 
 
65
        public int startRead() {
 
66
                return channel.startRead();
 
67
        }
 
68
        //End never used
 
69
 
 
70
        public void write(int n) {
 
71
                synchronized (writeMonitor) {
 
72
                        channel.write(n);
 
73
                }
 
74
 
 
75
        }
 
76
 
 
77
        public void writerPoison(int strength) {
 
78
                synchronized (writeMonitor) {
 
79
                        channel.writerPoison(strength);
 
80
                }
 
81
 
 
82
        }
 
83
 
 
84
        public AltingChannelInputInt in() {
 
85
                return new AltingChannelInputIntImpl(channel,0);
 
86
        }
 
87
 
 
88
        public SharedChannelOutputInt out() {
 
89
                return new SharedChannelOutputIntImpl(this,0);
 
90
        }
 
91
 
 
92
}