亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pooled_allocator.h

?? 簡單的動態內存管理程序源代碼
?? H
?? 第 1 頁 / 共 5 頁
字號:
// file: pooled_allocator.h// author: Marc Bumble// May 12, 2000// Memory allocator for shared memory access// Copyright (C) 2000 by Marc D. Bumble//  This program is free software; you can redistribute it and/or//  modify it under the terms of the GNU General Public License//  as published by the Free Software Foundation; either version 2//  of the License, or (at your option) any later version.//  This program is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//  GNU General Public License for more details.//  You should have received a copy of the GNU General Public License//  along with this program; if not, write to the Free Software//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.#include <iostream>#include <set>#include <map>#include <allocator_bit_vector.h>#include <shared_memory.h>#ifndef POOLED_ALLOCATOR_H#define POOLED_ALLOCATOR_H  namespace pooled_allocator {  // page_size  and  num_of_pages   are  constants  here.   The  mem  // variable is  static, so its parameters must  be declared before  // the class objects are instantiated.  enum {    page_size=8192,	      // Each segment is divided into pages of                              // this size    num_of_pages=1000,        // There are num_of_pages per segment    initial_num_of_elems=16   // Num of elems allocated in 1st chunk  };  ////////////////////////////////////////////////////////////////////  //////                           Class Chunk  ////////////////////////////////////////////////////////////////////  //////          //////        Unit of  pooled memory composed  of multiple elements.  //////        The Chunk objects are  allocated in Process memory.  A  //////        process  requests  pages  of  memory from  the  shared  //////        memory  segment  header.   There  is just  one  shared  //////        memory segment header  per shared memory segment.  The  //////        header is  located starting at  the first byte  of the  //////        shared memory segment.  Chunks  are allocated on a per  //////        process basis.  Once a  pool of memory is requested by  //////        the process, that process  is assigned the memory as a  //////        chunk.  Chunks are composed  of elements which are all  //////        of the same size.  //////          //////        A chunk manages  its memory on a per  chunk basis.  If  //////        one  chunks runs  out of  memory, than  the  Pool must  //////        request a  new chunk, and request  the required memory  //////        from the  new chunk.  Each chunk only  knows about its  //////        own elements.   They do  not know about  other chunks,  //////        except for links  to create lists of chunks  so that a  //////        set of chunks can be traversed.  //////          //////          ////////////////////////////////////////////////////////////////////    class Chunk  {    const int element_size;	// size of objects held in container    const int num_of_elements;	// num_of_elements in chunk    // const int page_size;	// page size of shared seg memory    const int memory_size;	// total element storage size in bytes    const int bit_vec_size;	// bit vector size    ///////////////////////////////////////////////////////////////////////////    //////        Chunk identification    ///////////////////////////////////////////////////////////////////////////    const int proj_id;	        // specific segment within series    const int segment_page_num;	// segment page number, used to compute offset                                // from the start of the segment to the chunk.    const int num_of_segment_pages;	// This chunk is composed of this many				// shared memory  segment pages.  When				// the  next chunk is  allocated, this				// value is used to determine the size				// of the next requested chunk.    char pathname[mem_space::name_length];  // identifies which segment series    int first_elem_num;		// first element number of this chunk    ///////////////////////////////////////////////////////////////////////////    // page free/allocated list    allocator_bit_vector::allocator_bit_vector_t bit_vec;    // data storage segment    unsigned char* mem;    // chunk to the beginning of the specific page_num    const int get_element_offset(int page_num);    // convert element number to pointer address    unsigned char* element_num_to_pointer(int start_block);    // Linked List implementation    Chunk* prev;  // points to prev chunk    Chunk* next;  // points to next chunk  public:    // constructor    // elem_size         - element   size    in    bytes.    // total_chunk_size  - The  chunk is  instantiated in  a  piece of    //                     memory which is total_chunk_size in bytes.    // proj_id           - The shared memory segement id or page    // segment_page_num  - The Chunk is on allocated starting at this    //                     page number within the shared memory segment    //                     identified by proj_id.    Chunk(const int& elem_size,	  const int& total_chunk_size,	  const int proj_id,	  const int segment_page_num);	// The  chunk  is instantiated					// in a  piece of memory which					// is    total_chunk_size   in					// bytes.    // destructor    virtual ~Chunk() {};    // copy constructor    Chunk(const Chunk& t);    // assignment operator    Chunk& operator=(const Chunk& t);    bool operator==(const Chunk& t);    // The  segment page  number is  the data  page number  within the    // segment  specified by  the pathname  and proj_id.   The segment    // page number  can be used  to compute the chunk_offset  which is    // the distance from the beginning of the shared memory segment to    // the beginning of this chunk  in bytes.  The chunk begins at the    // page boundary.    const int get_segment_page_num() {return segment_page_num;}    const int get_num_of_segment_pages() {return num_of_segment_pages;}    // get_page_offset returns the byte offset from the beginning of the    // Each chunk consists of a sequence of elements first_elem_num is    // the first global element number within this chunk.    void set_first_elem_num(int val) {first_elem_num=val;}    const int get_first_elem_num() {return first_elem_num;}    const int get_element_size() {return element_size;}    // bit_vec size is only for  the bit vector data, does not include    // header which is part of the Chunk class overhead.//     const int get_bit_vec_size() {return bit_vec_size;}    // num_of_elements is number of elements in this chunk    const int get_num_of_elements() {return num_of_elements;}    // pathname is the alloc_key used to retrieve the segment in which    // this chunk is embedded.   Pathname specifies a series of shared    // memory segments.    void set_pathname(char* path_name) {strcpy(pathname,path_name);}    void get_pathname(char* path_name) {strcpy(path_name,pathname);}    // The proj_id specifies which specific shared memory segment from    // within this series of shared memory segments.    const int get_proj_id() {return proj_id;}    // find num_of_elements contiguous free blocks    // returns local starting block number or -1    int find(int num_of_elements);    // mark num_of_elements starting at start_element    // as assigned.  This function is used to link    // newly freed memory with a previous free block.    void mark(int start_element,int num_of_elements);    // clear num_of_elements starting at start_element    // as available.    void clear(int start_element,int num_of_elements);    // Compute the element number associated with the pointer    int pointer_to_element_num(const unsigned char* p);    // allocate num_of_elements starting with    // element start_element    mem_space::memory_index_t    allocate(int start_element,	     int num_of_elements);    // release chunk elements    void free(int global_first_element, int num_of_elements);    // Functions for walking through the chunk list    Chunk* get_next(void) {return next;}    Chunk* get_prev(void) {return prev;}    void set_next(Chunk* val) {next=val;}    void set_prev(Chunk* val) {prev=val;}  };  // class Chunk        /////////////////////////////////////////////////////////////////////////////  //////                           Class Pool  /////////////////////////////////////////////////////////////////////////////  //////          //////        Class Pool maintains segments of memory which are stored as a  //////        as a list of chunks.  //////          /////////////////////////////////////////////////////////////////////////////    template<class T,	   mem_space::allocator_key_t alloc_key,           mem_space::allocator_addr_t alloc_addr=0>   class Pool {  private:    const int element_size;    // source of memory for the Pool    // static mem_space::shared<alloc_key,alloc_addr> mem;    mem_space::shared<alloc_key,alloc_addr> mem;        // chunks list is static so that all objects in the    // process share the same chunks    static Chunk* chunks; // list of allocated chunks    // Chunk* chunks; // list of allocated chunks    void grow();    int compute_chunk_pages();	// how  big should the  next allocated				// chunk be?    // locate shared memory to allocate the next chunk.    std::pair<mem_space::shared_memory_header_t*,int>    find_shared_memory(int requested_pages);    // local reference count//     int ref_count;  public:    // constructor    //    Pool(unsigned int sz,//     Pool(const int& esize);    Pool();    // destructor    virtual ~Pool();    // copy constructor    Pool(const Pool<T,alloc_key,alloc_addr>& t);    // assignment operator    Pool& operator=(const Pool<T,alloc_key,alloc_addr>& t);    // equality operator    bool operator==(const Pool<T,alloc_key,alloc_addr>& t) const;    Chunk* get_last_chunk();	// retrieve the last chunk in list    // find chunk associated with global_element_num    Chunk* find_chunk(int global_element_num);    // find_chunk finds the chunk and element number for pointer *p    std::pair<Chunk*,int> find_chunk(const unsigned char* p);    std::pair<Chunk*,int> find(int num_of_elements);    void mark(int start_element,int num_of_elements);    void clear(int start_element,int num_of_elements);    void free_chunk(Chunk* victim); // recycle chunk    // retrieve a specified shared memory page    mem_space::shared_memory_header_t*//     find_shared_segment() {    find_shared_segment(int proj_id) {      mem_space::memory_index_t smh_idx =	mem.allocate(proj_id);      return	static_cast<mem_space::shared_memory_header_t*>(smh_idx.get_memory_ptr());    };    mem_space::memory_index_t    alloc(const int num_of_elements);    void free(unsigned char* p, int num_of_elements);    // retrieve a pointer to the object//     unsigned char* retrieve_object_ptr(mem_space::memory_index_t obj_idx);    // get the allocator main index map    mem_space::map_index_t get_map_index(void);    // set the allocator main index map    void set_map_index(mem_space::map_index_t obj_idx);    void shutdown(void) {      // Close and release shared memory and semaphores      mem_space::shared_memory_header_t* smh =	find_shared_segment(1);      const int shared_memory_addr = smh->get_shared_memory_addr();      const int shared_memory_size = smh->get_shared_memory_size();//       smh->shutdown();      smh->~shared_memory_header_t();      mem.free(shared_memory_addr,shared_memory_size);    } // shutdown(void)    void lock(int segment_num, int segment_page_num) {      // lock access to the shared memory container      mem_space::shared_memory_header_t* smh =	find_shared_segment(segment_num);      smh->lock(segment_page_num);    }    void unlock(int segment_num, int segment_page_num) {      // unlock access to the shared memory container      mem_space::shared_memory_header_t* smh =	find_shared_segment(segment_num);      smh->unlock(segment_page_num);    }    Chunk* get_chunks_list(void) {      return chunks;    }    void set_chunks_list(Chunk* val) {      // first eliminate any existing chunks on the list      if ((chunks) && (chunks != val)) {	int chunkcount = 1;	Chunk* thischunk=chunks;	Chunk* prevchunk=0;	// get to the end of the list	while (thischunk->get_next()) {	  chunkcount++;	  prevchunk = thischunk;	  thischunk = thischunk->get_next();	}	if (chunkcount > 1) {	  // Flag a warning.   There should only be one  chunk at this	  // point.  This  function is  written to reassign  the first	  // chunk on  the list when it  is empty, ie  when no objects	  // are actually stored there.  If  more than one chunk is on	  // the list,  there is a  high probability that  objects are	  // already stored in the list.	  std::cerr << __FILE__ << ':' << __LINE__  << "Attempting to reset a loaded Chunk list."		    << std::endl;	}  // if (chunkcount > 1)	while (thischunk) {	  // run through the chunk list and release the current existing chunks	  free_chunk(thischunk);	  chunkcount--;	  thischunk = prevchunk;	  if (prevchunk)	    prevchunk = prevchunk->get_prev();	}  // while ((thischunk != chunks) && (thischunk != 0))	chunks = val;      }      // Then reset the chunk list to point to the list from the other      // process      return;    }    void unlink(void) {      // use  the map  in the  shared memory  class to  remove all      // related shared memory segments      mem.unlink();		// call shared class to unlink shared memory      return;    }  };  // class Pool//   // static elements of class Pool//   template<mem_space::allocator_t alloc_type,// 	   mem_space::allocator_key_t alloc_key,//            mem_space::allocator_addr_t alloc_addr=0> //   mem_space::shared<alloc_key,alloc_addr> Pool<alloc_type,// 			 alloc_key,alloc_addr>::mem(pooled_allocator::num_of_pages,// 					 pooled_allocator::page_size);    // static elements of class Pool  template<class T, 	   mem_space::allocator_key_t alloc_key,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品视频网| 美脚の诱脚舐め脚责91| 亚洲高清免费一级二级三级| 六月丁香婷婷久久| 欧美性色综合网| 中文字幕乱码一区二区免费| 国产一区二区三区不卡在线观看| 91高清视频在线| 国产精品热久久久久夜色精品三区 | 东方欧美亚洲色图在线| 91精品国产福利在线观看| 亚洲黄色片在线观看| 成人亚洲精品久久久久软件| 精品国一区二区三区| 日本视频免费一区| 欧美日韩一级二级三级| 亚洲免费av高清| 国产成人一区在线| 精品91自产拍在线观看一区| 日本 国产 欧美色综合| 欧美丝袜自拍制服另类| 亚洲精品中文字幕在线观看| 99久久综合国产精品| 国产精品色呦呦| 成人av免费在线| 国产精品每日更新在线播放网址| 国产真实精品久久二三区| 日韩精品一区二区三区在线| 美女一区二区在线观看| 制服丝袜成人动漫| 蜜桃久久久久久| 亚洲精品一线二线三线| 国产黄色成人av| 中文字幕乱码一区二区免费| www.欧美日韩| 亚洲精品久久久蜜桃| 欧美私人免费视频| 日本不卡123| 久久久久久久免费视频了| 高清不卡一区二区| 亚洲人成亚洲人成在线观看图片| 色94色欧美sute亚洲线路一ni | 狠狠色丁香九九婷婷综合五月| 日韩欧美在线网站| 国产专区欧美精品| 亚洲婷婷综合色高清在线| 日本久久电影网| 青青草成人在线观看| 国产日韩欧美a| 在线免费观看视频一区| 日本不卡一区二区| 久久精品视频一区| 在线免费观看日本一区| 日韩精品欧美成人高清一区二区| 欧美一级欧美三级| 成人一区二区三区| 亚洲黄色性网站| 精品国产91亚洲一区二区三区婷婷| 国产伦理精品不卡| 亚洲国产综合91精品麻豆| 337p亚洲精品色噜噜| 成人免费高清在线| 首页国产欧美日韩丝袜| 中文在线一区二区| 在线不卡免费av| 成人午夜视频网站| 欧美aaaaaa午夜精品| 国产精品二三区| 亚洲人精品午夜| 精品奇米国产一区二区三区| 99久久免费视频.com| 麻豆成人久久精品二区三区红 | 欧美在线观看视频一区二区| 另类欧美日韩国产在线| 亚洲精品免费在线| 久久久久久电影| 欧美日本视频在线| 成人激情文学综合网| 麻豆91小视频| 亚洲一区二区三区四区五区黄| 久久一日本道色综合| 在线不卡免费av| 91国产丝袜在线播放| 成人国产亚洲欧美成人综合网| 日韩一区精品字幕| 亚洲中国最大av网站| 国产精品国产三级国产有无不卡 | 免费一区二区视频| 一区二区三区精品视频| 国产日韩视频一区二区三区| 91精品国产全国免费观看| 欧洲激情一区二区| 成人精品鲁一区一区二区| 国产精品中文字幕日韩精品| 五月婷婷色综合| 亚洲线精品一区二区三区| 亚洲女人小视频在线观看| 国产欧美1区2区3区| 久久色视频免费观看| 欧美tickling网站挠脚心| 4438x亚洲最大成人网| 欧美午夜片在线观看| 在线免费观看成人短视频| 白白色亚洲国产精品| 粉嫩aⅴ一区二区三区四区| 国产精品一区一区| 国产麻豆精品在线| 国产不卡在线播放| 国产精品1区2区3区在线观看| 国产一区二区美女| 国产精品一区二区男女羞羞无遮挡| 免费视频一区二区| 精品一二三四区| 国产精品自在在线| 国产精品88888| 日韩视频在线观看一区二区| 91精品国产综合久久小美女| 91精品午夜视频| 3atv在线一区二区三区| 日韩欧美专区在线| 久久久五月婷婷| 亚洲欧洲无码一区二区三区| 最近日韩中文字幕| 亚洲一区二区三区四区在线| 天堂成人国产精品一区| 蜜桃传媒麻豆第一区在线观看| 韩国一区二区视频| 成人激情黄色小说| 欧美三级三级三级爽爽爽| 91精品国产91久久综合桃花| 精品久久久久一区| 亚洲婷婷综合久久一本伊一区 | 亚洲欧洲日韩一区二区三区| 亚洲免费资源在线播放| 亚洲成人免费av| 九一久久久久久| 99久久精品国产麻豆演员表| 欧美又粗又大又爽| 精品国产亚洲在线| 亚洲欧洲无码一区二区三区| 天天影视网天天综合色在线播放 | 日韩国产成人精品| 国产成人在线色| 国产精品伦理在线| 亚洲成av人**亚洲成av**| 精品综合久久久久久8888| 成人不卡免费av| 欧美日韩成人综合天天影院| 精品欧美一区二区久久| 欧美激情在线看| 婷婷丁香激情综合| 成人午夜伦理影院| 欧美一区二区性放荡片| 国产精品污www在线观看| 亚洲高清不卡在线| 成人av网址在线| 精品国产第一区二区三区观看体验| 中文字幕一区二区三区在线不卡| 日本不卡一区二区| 一本到不卡免费一区二区| 精品国产一区二区三区四区四| 亚洲免费av观看| 国产91丝袜在线观看| 91精品午夜视频| 亚洲永久精品大片| 成人美女视频在线观看18| 精品国产免费久久| 午夜在线电影亚洲一区| 99久久国产免费看| 久久久久国产精品免费免费搜索| 亚洲国产中文字幕在线视频综合| 风间由美中文字幕在线看视频国产欧美| 欧美色涩在线第一页| 综合网在线视频| 国产成人99久久亚洲综合精品| 欧美精品在线观看播放| 亚洲一区在线看| 色综合天天综合网天天狠天天| 久久精品亚洲一区二区三区浴池| 首页综合国产亚洲丝袜| 欧美影视一区二区三区| 亚洲欧美日韩国产综合| 国产成人免费视频| 久久久国产精品不卡| 久久国产婷婷国产香蕉| 制服.丝袜.亚洲.中文.综合| 亚洲一区欧美一区| 91精品福利在线| 一区二区三区不卡在线观看| 91视频国产资源| **欧美大码日韩| 91视频观看免费| 亚洲人成在线观看一区二区| 97久久精品人人澡人人爽| 国产精品看片你懂得| 91在线精品一区二区三区| 中文字幕制服丝袜成人av | 日韩三级视频在线观看| 久久电影网站中文字幕| 精品国产区一区|