2 * Copyright (C) 2009 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 // misc objects that need to get categorized
22 //=======================================================================
23 public class EflVala
.Command
: GLib
.Object
24 //=======================================================================
26 public string command
;
28 public Command( string command
)
30 this
.command
= command
;
31 debug( "creating command '%s' (%p)", command
, this
);
36 debug( "destructing command '%s' (%p)", this
.command
, this
);
40 //=======================================================================
41 public class EflVala
.BidirectionalThreadQueue
: GLib
.Object
42 //=======================================================================
44 public enum Identifier
49 private static QueueWithNotifier
<Command
> toGuiQ
;
50 private static QueueWithNotifier
<Command
> toCommQ
;
52 private Identifier owner
;
54 public BidirectionalThreadQueue( Identifier id
)
59 case Identifier
.COMMUNICATION_THREAD
:
60 assert ( toGuiQ
== null );
61 toGuiQ
= new QueueWithNotifier
<Command
>();
63 case Identifier
.GUI_THREAD
:
64 assert ( toCommQ
== null );
65 toCommQ
= new QueueWithNotifier
<Command
>();
72 public void getFds( out int readfd
, out int writefd
)
76 case Identifier
.COMMUNICATION_THREAD
:
77 readfd
= toCommQ
.getReadFd();
78 writefd
= toGuiQ
.getWriteFd();
80 case Identifier
.GUI_THREAD
:
81 readfd
= toGuiQ
.getReadFd();
82 writefd
= toCommQ
.getWriteFd();
89 public Command?
read()
93 case Identifier
.COMMUNICATION_THREAD
:
94 return toCommQ
.read();
96 case Identifier
.GUI_THREAD
:
100 assert_not_reached();
104 public void write( Command command
)
108 case Identifier
.COMMUNICATION_THREAD
:
109 toGuiQ
.write( command
);
111 case Identifier
.GUI_THREAD
:
112 toCommQ
.write( command
);
115 assert_not_reached();