00001 /* 00002 This file is part of GraphLab. 00003 00004 GraphLab is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as 00006 published by the Free Software Foundation, either version 3 of 00007 the License, or (at your option) any later version. 00008 00009 GraphLab is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public 00015 License along with GraphLab. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef DC_SEND_HPP 00019 #define DC_SEND_HPP 00020 #include <iostream> 00021 #include <graphlab/rpc/dc_internal_types.hpp> 00022 #include <graphlab/rpc/dc_types.hpp> 00023 namespace graphlab { 00024 namespace dc_impl { 00025 00026 /** 00027 \ingroup rpc_internal 00028 Base class of the data sending class. 00029 This class forms the sending side of a "multiplexer" 00030 send_data() will be called with a packet mask as well as a 00031 character stream containing the contents of the packet. 00032 This class must then transmit the data out of the associated 00033 comms. 00034 */ 00035 class dc_send{ 00036 public: 00037 dc_send() { } 00038 virtual ~dc_send() { } 00039 /** 00040 Called by the controller when there is data to send. 00041 if len is -1, the function has to compute the length by itself, 00042 or send the data from the stream directly. the strm is not copyable. 00043 */ 00044 virtual void send_data(procid_t target, 00045 unsigned char packet_type_mask, 00046 std::istream &istrm, 00047 size_t len = size_t(-1)) = 0; 00048 /** Another possible interface the controller can 00049 call with when there is data to send. The caller has 00050 responsibility for freeing the pointer when this call returns*/ 00051 virtual void send_data(procid_t target, 00052 unsigned char packet_type_mask, 00053 char* data, size_t len) = 0; 00054 00055 /** 00056 Bytes sent must be incremented BEFORE the data is transmitted. 00057 Packets marked CONTROL_PACKET should not be counted 00058 */ 00059 virtual size_t bytes_sent() = 0; 00060 00061 00062 /** returns true if the channel to the target 00063 machine is truly open. The dc_comm_base specification allows 00064 for lazy channels which are not created until it is used. 00065 For such implementations, this function should return true 00066 if the channel has been created, and false otherwise. Non-lazy 00067 implementations should return true all the time. 00068 The invariant to ensure is that this function must return true 00069 for a target machine ID if a packet has been sent from this machine 00070 to the target before this call. 00071 */ 00072 virtual bool channel_active(procid_t target) const = 0; 00073 00074 /** 00075 * Last call sent to any instance of dc_send. 00076 * If the sender multithreads, the sending thread must shut down. 00077 */ 00078 virtual void shutdown() = 0; 00079 00080 }; 00081 00082 00083 } // namespace dc_impl 00084 } // namespace graphlab 00085 #endif 00086
1.7.1