• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

InkPool_r.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef __INK_POOL_R_H_INCLUDED__
00025 #define __INK_POOL_R_H_INCLUDED__
00026 
00027 #include "InkPool.h"
00028 #include "P_EventSystem.h"
00029 
00030 template<class C> class InkStaticPool_r:
00031 public InkStaticPool<C> {
00032 public:
00033   InkStaticPool_r(int size):InkStaticPool<C> (size)
00034   {
00035     mutex = new_ProxyMutex();
00036   }
00037 
00038   virtual ~ InkStaticPool_r() {
00039     MUTEX_LOCK(lock, mutex, this_ethread());
00040     cleanUp();
00041   }
00042 
00043   C *get()
00044   {
00045     MUTEX_LOCK(lock, mutex, this_ethread());
00046     return (InkStaticPool<C>::get());
00047   }
00048 
00049   bool put(C * newObj)
00050   {
00051     MUTEX_LOCK(lock, mutex, this_ethread());
00052     return (InkStaticPool<C>::put(newObj));
00053   }
00054 
00055   void put_or_delete(C * newObj)
00056   {
00057     if (!this->put(newObj))
00058       delete newObj;
00059   }
00060 
00061   ProxyMutex *getMutex()
00062   {
00063     return (mutex);
00064   }
00065 
00066 protected:
00067   Ptr<ProxyMutex> mutex;
00068 };
00069 
00070 
00071 #endif // #ifndef __INK_POOL_R_H_INCLUDED__

Generated by  doxygen 1.7.1