summaryrefslogtreecommitdiff
path: root/cache_8h-source.html
blob: 9b968e8fe1687a9c6aca02657786f5d39bc67fad (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
68
69
70
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>memcached: cache.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>cache.h</h1><a href="cache_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */</span>
<a name="l00002"></a>00002 <span class="preprocessor">#ifndef CACHE_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span><span class="preprocessor">#define CACHE_H</span>
<a name="l00004"></a>00004 <span class="preprocessor"></span><span class="preprocessor">#include &lt;pthread.h&gt;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#ifdef HAVE_UMEM_H</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span><span class="preprocessor">#include &lt;umem.h&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#define cache_t umem_cache_t</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define cache_free(a, b) umem_cache_free(a, b)</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0)</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#define cache_destroy(a) umem_cache_destroy(a);</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span>
<a name="l00014"></a>00014 <span class="preprocessor">#else</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#ifndef NDEBUG</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="comment">/* may be used for debug purposes */</span>
<a name="l00018"></a>00018 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="cache_8c.html#d4f8c8851cbc2284dc3af57ed3601b6b">cache_error</a>;
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00029"></a><a class="code" href="cache_8h.html#565b39d1034d5aaccafd0e996904eebc">00029</a> <span class="keyword">typedef</span> <span class="keywordtype">int</span> <a class="code" href="cache_8h.html#565b39d1034d5aaccafd0e996904eebc" title="Constructor used to initialize allocated objects.">cache_constructor_t</a>(<span class="keywordtype">void</span>* obj, <span class="keywordtype">void</span>* notused1, <span class="keywordtype">int</span> notused2);
<a name="l00039"></a><a class="code" href="cache_8h.html#7ac51941cc19301c6ce8b7c4a3d5dd9c">00039</a> <span class="keyword">typedef</span> <span class="keywordtype">void</span> <a class="code" href="cache_8h.html#7ac51941cc19301c6ce8b7c4a3d5dd9c" title="Destructor used to clean up allocated objects before they are returned to the operating...">cache_destructor_t</a>(<span class="keywordtype">void</span>* obj, <span class="keywordtype">void</span>* notused);
<a name="l00040"></a>00040 
<a name="l00046"></a><a class="code" href="structcache__t.html">00046</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00048"></a><a class="code" href="structcache__t.html#bd82ae1c6f8afecb2d59c606b6b363a6">00048</a>     pthread_mutex_t mutex;
<a name="l00050"></a><a class="code" href="structcache__t.html#a2126af24d1226c9ba341cbbecde245b">00050</a>     <span class="keywordtype">char</span> *name;
<a name="l00052"></a><a class="code" href="structcache__t.html#0434599c19031c52b6a4fe98b443a073">00052</a>     <span class="keywordtype">void</span> **ptr;
<a name="l00054"></a><a class="code" href="structcache__t.html#85f861c4628b5cf099f95594cd64df27">00054</a>     <span class="keywordtype">size_t</span> bufsize;
<a name="l00056"></a><a class="code" href="structcache__t.html#24f29d93303d192bcbfc87dda3ef296b">00056</a>     <span class="keywordtype">int</span> freetotal;
<a name="l00058"></a><a class="code" href="structcache__t.html#e01151c875560f6f7fb91208bbbcdbb6">00058</a>     <span class="keywordtype">int</span> freecurr;
<a name="l00060"></a><a class="code" href="structcache__t.html#673b6ff5141c7dcbc97c2f8756a5b7bc">00060</a>     <a class="code" href="cache_8h.html#565b39d1034d5aaccafd0e996904eebc" title="Constructor used to initialize allocated objects.">cache_constructor_t</a>* constructor;
<a name="l00062"></a><a class="code" href="structcache__t.html#41c291d17863ce98057bbcb01fd27719">00062</a>     <a class="code" href="cache_8h.html#7ac51941cc19301c6ce8b7c4a3d5dd9c" title="Destructor used to clean up allocated objects before they are returned to the operating...">cache_destructor_t</a>* destructor;
<a name="l00063"></a>00063 } <a class="code" href="structcache__t.html" title="Definition of the structure to keep track of the internal details of the cache allocator...">cache_t</a>;
<a name="l00064"></a>00064 
<a name="l00083"></a>00083 <a class="code" href="structcache__t.html" title="Definition of the structure to keep track of the internal details of the cache allocator...">cache_t</a>* <a class="code" href="cache_8c.html#631fa31e902ac58f80d0374ffed1d486" title="Create an object cache.">cache_create</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">size_t</span> align,
<a name="l00084"></a>00084                       <a class="code" href="cache_8h.html#565b39d1034d5aaccafd0e996904eebc" title="Constructor used to initialize allocated objects.">cache_constructor_t</a>* constructor,
<a name="l00085"></a>00085                       <a class="code" href="cache_8h.html#7ac51941cc19301c6ce8b7c4a3d5dd9c" title="Destructor used to clean up allocated objects before they are returned to the operating...">cache_destructor_t</a>* destructor);
<a name="l00095"></a>00095 <span class="keywordtype">void</span> <a class="code" href="cache_8c.html#81a74098387faa1e105aa3e9e1d60a5e" title="Destroy an object cache.">cache_destroy</a>(<a class="code" href="structcache__t.html" title="Definition of the structure to keep track of the internal details of the cache allocator...">cache_t</a>* handle);
<a name="l00103"></a>00103 <span class="keywordtype">void</span>* <a class="code" href="cache_8c.html#6cc4f3f91247554c4961a0cb8acc298f" title="Allocate an object from the cache.">cache_alloc</a>(<a class="code" href="structcache__t.html" title="Definition of the structure to keep track of the internal details of the cache allocator...">cache_t</a>* handle);
<a name="l00113"></a>00113 <span class="keywordtype">void</span> <a class="code" href="cache_8c.html#a1906b5ce5a39f760454519441f3e0b9" title="Return an object back to the cache.">cache_free</a>(<a class="code" href="structcache__t.html" title="Definition of the structure to keep track of the internal details of the cache allocator...">cache_t</a>* handle, <span class="keywordtype">void</span>* ptr);
<a name="l00114"></a>00114 <span class="preprocessor">#endif</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span>
<a name="l00116"></a>00116 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Apr 17 16:28:06 2009 for memcached by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>