~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/system/public/apr_thread_compatible_pool.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2012 Google Inc.
2
 
//
3
 
// Licensed under the Apache License, Version 2.0 (the "License");
4
 
// you may not use this file except in compliance with the License.
5
 
// You may obtain a copy of the License at
6
 
//
7
 
//      http://www.apache.org/licenses/LICENSE-2.0
8
 
//
9
 
// Unless required by applicable law or agreed to in writing, software
10
 
// distributed under the License is distributed on an "AS IS" BASIS,
11
 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
// See the License for the specific language governing permissions and
13
 
// limitations under the License.
14
 
//
15
 
// Author: morlovich@google.com (Maksim Orlovich)
16
 
//         jmarantz@google.com (Joshua Marantz)  (refactoring only)
17
 
 
18
 
#ifndef NET_INSTAWEB_SYSTEM_PUBLIC_APR_THREAD_COMPATIBLE_POOL_H_
19
 
#define NET_INSTAWEB_SYSTEM_PUBLIC_APR_THREAD_COMPATIBLE_POOL_H_
20
 
 
21
 
#include "apr_pools.h"
22
 
 
23
 
namespace net_instaweb {
24
 
 
25
 
// Creates a pool that can be used in any thread, even when run in
26
 
// Apache prefork.
27
 
//
28
 
// 1) This method must be called from startup phase only
29
 
// 2) Each pool must be accessed only from a single thread (or otherwise
30
 
//    have its access serialized)
31
 
// 3) Different pools returned by this function may be safely used concurrently.
32
 
// 4) It's OK to just use ap_pool_create to create child pools of this one from
33
 
//    multiple threads; those will be re-entrant too (but pools created merely
34
 
//    as children of Apache's pools will not be reentrant in prefork)
35
 
//
36
 
// In short, pools returned by this method are not fully threadsafe, but
37
 
// at least they are not thread-hostile, which is what you get with
38
 
// apr_pool_create in Prefork.
39
 
//
40
 
// Note: the above is all about the release version of the pool code, the
41
 
// checking one has some additional locking!
42
 
//
43
 
// WARNING: you must not call apr_pool_clear on the returned pool.  The
44
 
// returned pool can be used to create sub-pools that can be accessed
45
 
// in distinct threads, due to a mutex injected into the allocator.
46
 
// However, if you call apr_pool_clear on the returned pool, the allocator's
47
 
// mutex will be freed and the pointer to it will be dangling.  Subsequent
48
 
// allocations are likely to crash.
49
 
apr_pool_t* AprCreateThreadCompatiblePool(apr_pool_t* parent_pool);
50
 
 
51
 
}  // namespace net_instaweb
52
 
 
53
 
#endif  // NET_INSTAWEB_SYSTEM_PUBLIC_APR_THREAD_COMPATIBLE_POOL_H_