?? main.cc
字號:
// file: main.cc// author: Marc Bumble// April 29, 2003// Page memory source for shared memory // Copyright (C) 2003 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 <pooled_allocator.h>#include <vector>char key_val[] = "/allocate_key"; // needs a leading slash, see manpage.char key_container[] = "container_lookup_key";char key_addr[] = "0x400d0000";int main(int argc, char** argv) { typedef pooled_allocator::Pool_alloc<int, key_val, key_addr> my_vector_alloc_t; typedef std::vector<int,my_vector_alloc_t> my_vector_t; pooled_allocator::Multi_Process_Pool_alloc<my_vector_t, int, key_val, key_container, key_addr> temp_alloc; my_vector_t* vec_ptr = temp_alloc.attach(); const int& segment_num = temp_alloc.get_proj_id(); const int& segment_page_num = temp_alloc.get_segment_page_num(); temp_alloc.lock(segment_num,segment_page_num); std::cout << "Insert ints" << std::endl; for (int i = 0; i < 5000; i++) { vec_ptr->push_back(i); std::cout << "Pushed a " << i << "\t Read a " << (*vec_ptr)[i] << std::endl; }; temp_alloc.unlock(segment_num,segment_page_num); std::cout << "Read 1st time" << std::endl; for (my_vector_t::iterator it = vec_ptr->begin(); it != vec_ptr->end(); it++) std::cout << "Vector val: " << *it << std::endl; std::cout << "Read 2nd time" << std::endl; for (my_vector_t::iterator it = vec_ptr->begin(); it != vec_ptr->end(); it++) std::cout << "Vector val: " << *it << std::endl; return 0;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -