~ubuntu-branches/ubuntu/oneiric/libktorrent/oneiric

« back to all changes in this revision

Viewing changes to src/utp/outputqueue.h

  • Committer: Bazaar Package Importer
  • Author(s): Modestas Vainius
  • Date: 2011-05-26 00:33:38 UTC
  • mfrom: (5.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110526003338-2r4zwyzn8bovsxay
Tags: 1.1.1-2
Release to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2010 by Joris Guisson                                   *
 
3
 *   joris.guisson@gmail.com                                               *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 
19
 ***************************************************************************/
 
20
 
 
21
 
 
22
#ifndef UTP_OUTPUTQUEUE_H
 
23
#define UTP_OUTPUTQUEUE_H
 
24
 
 
25
#include <QList>
 
26
#include <QByteArray>
 
27
#include <net/serversocket.h>
 
28
#include "connection.h"
 
29
 
 
30
 
 
31
namespace utp 
 
32
{
 
33
        /**
 
34
         * Manages the send queue of all UTP server sockets
 
35
         */
 
36
        class OutputQueue
 
37
        {
 
38
        public:
 
39
                OutputQueue();
 
40
                virtual ~OutputQueue();
 
41
                
 
42
                /**
 
43
                 * Add an entry to the queue.
 
44
                 * @param data The packet
 
45
                 * @param conn The connection this packet belongs to
 
46
                 * @return The number of queued packets
 
47
                 */
 
48
                int add(const QByteArray & data, Connection::WPtr conn);
 
49
                
 
50
                /**
 
51
                 * Attempt to send the queue on a socket
 
52
                 * @param sock The socket
 
53
                 */
 
54
                void send(net::ServerSocket* sock);
 
55
                
 
56
        private:
 
57
                struct Entry
 
58
                {
 
59
                        QByteArray data;
 
60
                        Connection::WPtr conn;
 
61
                        
 
62
                        Entry(const QByteArray & data, Connection::WPtr conn)
 
63
                        : data(data),conn(conn)
 
64
                        {}
 
65
                };
 
66
                
 
67
                QList<Entry> queue;
 
68
                QMutex mutex;
 
69
        };
 
70
 
 
71
}
 
72
 
 
73
#endif // UTP_OUTPUTQUEUE_H