2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
7 #include <ServerInterface.h>
14 #include <DataExchange.h>
22 class PortPool
: BLocker
{
28 void PutPort(port_id port
);
31 typedef std::set
<port_id
> PortSet
;
37 static PortPool sPortPool
;
49 PortSet::iterator iterator
= fPool
.begin();
51 for (; iterator
!= fPool
.end(); iterator
++)
52 delete_port(*iterator
);
62 return create_port(1, "media reply port");
64 port_id port
= *fPool
.begin();
73 PortPool::PutPort(port_id port
)
81 } catch (std::bad_alloc
& exception
) {
90 request_data::request_data()
92 reply_port
= sPortPool
.GetPort();
96 request_data::~request_data()
98 sPortPool
.PutPort(reply_port
);
103 request_data::SendReply(status_t result
, reply_data
*reply
,
104 size_t replySize
) const
106 reply
->result
= result
;
107 // we cheat and use the (command_data *) version of SendToPort
108 return SendToPort(reply_port
, 0, reinterpret_cast<command_data
*>(reply
),
114 } // namespace BPrivate