|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2013, Peter Thorson. All rights reserved. |
| 2 | + * Copyright (c) 2014, Peter Thorson. All rights reserved. |
3 | 3 | *
|
4 | 4 | * Redistribution and use in source and binary forms, with or without
|
5 | 5 | * modification, are permitted provided that the following conditions are met:
|
|
29 | 29 | #define WEBSOCKETPP_CONCURRENCY_NONE_HPP
|
30 | 30 |
|
31 | 31 | namespace websocketpp {
|
| 32 | + |
| 33 | +/// Concurrency handling support |
32 | 34 | namespace concurrency {
|
33 | 35 |
|
| 36 | +/// Implementation for no-op locking primitives |
34 | 37 | namespace none_impl {
|
| 38 | +/// A fake mutex implementation that does nothing |
35 | 39 | class fake_mutex {
|
36 | 40 | public:
|
37 | 41 | fake_mutex() {}
|
38 | 42 | ~fake_mutex() {}
|
39 | 43 | };
|
40 | 44 |
|
| 45 | +/// A fake lock guard implementation that does nothing |
41 | 46 | class fake_lock_guard {
|
42 | 47 | public:
|
43 | 48 | explicit fake_lock_guard(fake_mutex foo) {}
|
44 | 49 | ~fake_lock_guard() {}
|
45 | 50 | };
|
46 | 51 | } // namespace none_impl
|
47 | 52 |
|
48 |
| -/// Stub Concurrency policy to remove locking in single threaded projects |
| 53 | +/// Stub concurrency policy that implements the interface using no-ops. |
| 54 | +/** |
| 55 | + * This policy documents the concurrency policy interface using no-ops. It can |
| 56 | + * be used as a reference or base for building a new concurrency policy. It can |
| 57 | + * also be used as is to disable all locking for endpoints used in purely single |
| 58 | + * threaded programs. |
| 59 | + */ |
49 | 60 | class none {
|
50 | 61 | public:
|
| 62 | + /// The type of a mutex primitive |
| 63 | + /** |
| 64 | + * std::mutex is an example. |
| 65 | + */ |
51 | 66 | typedef none_impl::fake_mutex mutex_type;
|
| 67 | + |
| 68 | + /// The type of a scoped/RAII lock primitive. |
| 69 | + /** |
| 70 | + * The scoped lock constructor should take a mutex_type as a parameter, |
| 71 | + * acquire that lock, and release it in its destructor. std::lock_guard is |
| 72 | + * an example. |
| 73 | + */ |
52 | 74 | typedef none_impl::fake_lock_guard scoped_lock_type;
|
53 | 75 | };
|
54 | 76 |
|
|
0 commit comments