www.pudn.com > allocator.rar > connect.cc


// file: connect.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   
#include 
#include 

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 my_vector_alloc_t;
  
  typedef std::vector my_vector_t;

  pooled_allocator::Multi_Process_Pool_alloc temp_alloc;

  my_vector_t* vec_ptr = temp_alloc.attach();
  for (my_vector_t::iterator it = vec_ptr->begin();
       it != vec_ptr->end(); it++)
    std::cout << "Vector val: " << *it << std::endl;
  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);
  vec_ptr->push_back(11);
  vec_ptr->push_back(12);
  vec_ptr->push_back(13);
  vec_ptr->push_back(14);
  temp_alloc.unlock(segment_num,segment_page_num);
  
  return 0;

}