xoreos  0.0.5
requesttypes.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/error.h"
26 #include "src/common/util.h"
27 
29 #include "src/events/events.h"
30 
31 namespace Events {
32 
33 Request::Request(ITCEvent type) : _type(type), _dispatched(false), _garbage(false),
34  _hasReply(0) {
35 
36  create();
37 }
38 
40 }
41 
42 bool Request::isGarbage() const {
43  // Only "really" garbage if it hasn't got a pending answer
44  return _garbage && !_dispatched;
45 }
46 
48  _garbage = true;
49 }
50 
52  _event.type = kEventITC;
53  _event.user.code = (int) _type;
54  _event.user.data1 = static_cast<void *>(this);
55 }
56 
58  _hasReply.unlock();
59 }
60 
62 }
63 
64 } // End of namespace Events
void create()
Create the empty request frame.
void signalReply()
Signal that the request was answered.
Event _event
The actual event.
Definition: requesttypes.h:67
Inter-thread communication.
Definition: types.h:56
ITCEvent _type
Definition: requesttypes.h:60
Basic exceptions to throw.
Utility templates and functions.
bool isGarbage() const
void copyToReply()
Copy reply data to the reply address.
The global events manager.
ITCEvent
Specific type of the inter-thread communication.
Definition: types.h:70
Request(ITCEvent type)
Common::Semaphore _hasReply
Do we have a reply?
Definition: requesttypes.h:65
void unlock()
Definition: mutex.cpp:75
Inter-thread request event types.
bool _dispatched
Was the request dispatched?
Definition: requesttypes.h:62