summaryrefslogtreecommitdiff
path: root/src/mongo/db/pagefault.h
blob: dd3697f13f136324fd0146e776f34b62d6b835d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// @file pagefault.h

// define this : _PAGEFAULTEXCEPTION

#pragma once

namespace mongo {

    class Record;

    class PageFaultException /*: public DBException*/ { 
        unsigned era;
        Record *r;
    public:
        PageFaultException(const PageFaultException& rhs) : era(rhs.era), r(rhs.r) { }
        explicit PageFaultException(Record*);
        void touch();
    };

    class PageFaultRetryableSection : boost::noncopyable { 
        unsigned _laps;
    public:
        unsigned laps() const { return _laps; }
        void didLap() { _laps++; }
        PageFaultRetryableSection();
        ~PageFaultRetryableSection();
    };
#if 0
    inline void how_to_use_example() {
        // ...
        {
            PageFaultRetryableSection s;
            while( 1 ) {
                try {
                    writelock lk; // or readlock
                    // do work
                    break;
                }
                catch( PageFaultException& e ) { 
                    e.touch();
                } 
            }
        }
        // ...
    }
#endif
}