~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/disk_buffer_holder.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#define TORRENT_DISK_BUFFER_HOLDER_HPP_INCLUDED
35
35
 
36
36
#include "libtorrent/config.hpp"
 
37
#include "libtorrent/assert.hpp"
 
38
#include <algorithm>
37
39
 
38
40
namespace libtorrent
39
41
{
40
42
 
41
 
        namespace aux { class session_impl; }
42
 
        class disk_io_thread;
 
43
        namespace aux { struct session_impl; }
 
44
        struct disk_buffer_pool;
43
45
 
44
46
        struct TORRENT_EXPORT disk_buffer_holder
45
47
        {
46
48
                disk_buffer_holder(aux::session_impl& ses, char* buf);
47
 
                disk_buffer_holder(disk_io_thread& iothread, char* buf);
 
49
                disk_buffer_holder(disk_buffer_pool& disk_pool, char* buf);
 
50
                disk_buffer_holder(disk_buffer_pool& disk_pool, char* buf, int num_blocks);
48
51
                ~disk_buffer_holder();
49
52
                char* release();
50
53
                char* get() const { return m_buf; }
51
 
                void reset(char* buf = 0);
 
54
                void reset(char* buf = 0, int num_blocks = 1);
 
55
                void swap(disk_buffer_holder& h)
 
56
                {
 
57
                        TORRENT_ASSERT(&h.m_disk_pool == &m_disk_pool);
 
58
                        std::swap(h.m_buf, m_buf);
 
59
                }
52
60
 
53
61
                typedef char* (disk_buffer_holder::*unspecified_bool_type)();
54
62
                operator unspecified_bool_type() const
55
63
                { return m_buf == 0? 0: &disk_buffer_holder::release; }
56
64
 
57
65
        private:
58
 
                disk_io_thread& m_iothread;
 
66
                disk_buffer_pool& m_disk_pool;
59
67
                char* m_buf;
 
68
                int m_num_blocks;
60
69
        };
61
70
 
62
71
}