add original source
This commit is contained in:
27
source/listing_4.10.cpp
Normal file
27
source/listing_4.10.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <future>
|
||||
void process_connections(connection_set& connections)
|
||||
{
|
||||
while(!done(connections))
|
||||
{
|
||||
for(connection_iterator
|
||||
connection=connections.begin(),end=connections.end();
|
||||
connection!=end;
|
||||
++connection)
|
||||
{
|
||||
if(connection->has_incoming_data())
|
||||
{
|
||||
data_packet data=connection->incoming();
|
||||
std::promise<payload_type>& p=
|
||||
connection->get_promise(data.id);
|
||||
p.set_value(data.payload);
|
||||
}
|
||||
if(connection->has_outgoing_data())
|
||||
{
|
||||
outgoing_packet data=
|
||||
connection->top_of_outgoing_queue();
|
||||
connection->send(data.payload);
|
||||
data.promise.set_value(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user