network_worker.hpp

Go to the documentation of this file.
00001 /* $Id: network_worker.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef NETWORK_WORKER_HPP_INCLUDED
00017 #define NETWORK_WORKER_HPP_INCLUDED
00018 
00019 #include <map>
00020 #include "network.hpp"
00021 
00022 class config;
00023 
00024 /**
00025  * Aligns a variable on a 4 byte boundary.
00026  *
00027  * The address needs to be aligned on a Sparc system, if it's not aligned the
00028  * SDLNet_Read32 call will cause a SIGBUS and the server will be terminated [1].
00029  * Best use this alignment for all buffers used in for the SDL_Net calls.
00030  *
00031  * [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=426318
00032  */
00033 #ifdef __GNUC__
00034 #define ALIGN_4 __attribute__ ((aligned (4)))
00035 #else
00036 #define ALIGN_4
00037 #endif
00038 
00039 namespace network_worker_pool
00040 {
00041 
00042 struct manager
00043 {
00044     explicit manager(size_t min_threads,size_t max_threads);
00045     ~manager();
00046 
00047 private:
00048     manager(const manager&);
00049     void operator=(const manager&);
00050 
00051     bool active_;
00052 };
00053 
00054 network::pending_statistics get_pending_stats();
00055 
00056 void set_raw_data_only();
00057 void set_use_system_sendfile(bool);
00058 
00059 /** Function to asynchronously received data to the given socket. */
00060 void receive_data(TCPsocket sock);
00061 
00062 TCPsocket get_received_data(TCPsocket sock, config& cfg, network::bandwidth_in_ptr&);
00063 
00064 TCPsocket get_received_data(std::vector<char>& buf);
00065 
00066 void queue_file(TCPsocket sock, const std::string&);
00067 
00068 void queue_raw_data(TCPsocket sock, const char* buf, int len);
00069 size_t queue_data(TCPsocket sock, const config& buf, const std::string& packet_type);
00070 bool is_locked(const TCPsocket sock);
00071 bool close_socket(TCPsocket sock);
00072 TCPsocket detect_error();
00073 
00074 std::pair<network::statistics,network::statistics> get_current_transfer_stats(TCPsocket sock);
00075 
00076 }
00077 
00078 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:07 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs