blob: ba2f64f5126270be7ec3a7fc200cdea5f60fb63f (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// @file d_concurrency.h
#pragma once
#include "../util/concurrency/rwlock.h"
#include "db/mongomutex.h"
namespace mongo {
namespace clcimpl {
enum LockStates { Unlocked, AcquireShared=1, LockedShared=2, AcquireExclusive=4, LockedExclusive=8 };
class Shared : boost::noncopyable {
unsigned& state;
RWLock *rw;
public:
Shared(unsigned& state, RWLock& lock);
~Shared();
bool recursed() const { return rw == 0; }
};
class Exclusive : boost::noncopyable {
unsigned& state;
RWLock *rw;
public:
Exclusive(unsigned& state, RWLock& lock);
~Exclusive();
};
}
typedef readlock GlobalSharedLock;
class ExcludeAllWrites : boost::noncopyable {
clcimpl::Exclusive lk;
GlobalSharedLock gslk;
public:
ExcludeAllWrites();
~ExcludeAllWrites();
};
class todoGlobalWriteLock : boost::noncopyable {
public:
};
class LockCollectionForReading : boost::noncopyable {
GlobalSharedLock gslk;
clcimpl::Shared clk;
public:
LockCollectionForReading(string coll);
~LockCollectionForReading();
};
#if defined(CLC)
class LockCollectionForWriting : boost::noncopyable {
struct Locks {
Locks(string ns);
SimpleRWLock::Shared excluder;
GlobalSharedLock gslk;
rwlock clk;
};
scoped_ptr<Locks> locks;
public:
LockCollectionForWriting(string db);
~LockCollectionForWriting();
};
#else
#endif
}
|