diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-31 21:48:20 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-31 21:48:20 +0000 |
commit | 86c5f836d1a679208716a422839d7da38ba41059 (patch) | |
tree | 1b3da514a0eb2064d0b27c62011db9492387b7dc /examples/Shared_Malloc | |
parent | 13c10349a654c59c85bb62c7f7b9ab8e1424814c (diff) | |
download | ATCD-86c5f836d1a679208716a422839d7da38ba41059.tar.gz |
added ACE_HAS_INSTANTIATION_PRAGMA support
Diffstat (limited to 'examples/Shared_Malloc')
-rw-r--r-- | examples/Shared_Malloc/Malloc.cpp | 31 | ||||
-rw-r--r-- | examples/Shared_Malloc/test_persistence.cpp | 52 |
2 files changed, 57 insertions, 26 deletions
diff --git a/examples/Shared_Malloc/Malloc.cpp b/examples/Shared_Malloc/Malloc.cpp index 403d8325b23..1d6afed68da 100644 --- a/examples/Shared_Malloc/Malloc.cpp +++ b/examples/Shared_Malloc/Malloc.cpp @@ -52,7 +52,7 @@ Malloc::instance (void) return Malloc::instance_; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Allocator_Adapter<L_ALLOCATOR>; template class ACE_Allocator_Adapter<M_ALLOCATOR>; template class ACE_Allocator_Adapter<SB_ALLOCATOR>; @@ -78,4 +78,31 @@ template class ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX>; #else template class ACE_Malloc <ACE_SBRK_MEMORY_POOL, ACE_SYNCH_MUTEX>; #endif /* ACE_LACKS_SBRK */ -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Allocator_Adapter<L_ALLOCATOR> +#pragma instantiate ACE_Allocator_Adapter<M_ALLOCATOR> +#pragma instantiate ACE_Allocator_Adapter<SB_ALLOCATOR> +#pragma instantiate ACE_Allocator_Adapter<SP_ALLOCATOR> +#pragma instantiate ACE_Allocator_Adapter<ST_ALLOCATOR> +#pragma instantiate ACE_Guard<ACE_Process_Mutex> +#pragma instantiate ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX> +#pragma instantiate ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_Process_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_SYNCH_MUTEX> +#pragma instantiate ACE_Write_Guard<ACE_Process_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_SYNCH_MUTEX> + +#if defined (ACE_LACKS_SYSV_SHMEM) +#pragma instantiate ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX> +#else +#pragma instantiate ACE_Malloc <ACE_SHARED_MEMORY_POOL, ACE_Process_Mutex> +#pragma instantiate ACE_Malloc <ACE_SHARED_MEMORY_POOL, ACE_SYNCH_MUTEX> +#endif /* ACE_LACKS_SYSV_SHMEM */ + +#if defined (ACE_LACKS_SBRK) +#pragma instantiate ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX> +#else +#pragma instantiate ACE_Malloc <ACE_SBRK_MEMORY_POOL, ACE_SYNCH_MUTEX> +#endif /* ACE_LACKS_SBRK */ +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Shared_Malloc/test_persistence.cpp b/examples/Shared_Malloc/test_persistence.cpp index 1392a210442..15505950635 100644 --- a/examples/Shared_Malloc/test_persistence.cpp +++ b/examples/Shared_Malloc/test_persistence.cpp @@ -43,7 +43,7 @@ public: u_long id (void) const { return id_; } void id (u_long id) { id_ = id; } - + friend ostream &operator<<(ostream &stream, const Employee &employee) { stream << endl; @@ -53,7 +53,7 @@ public: return stream; } - + void *operator new (size_t) { return shmem_manager->malloc (sizeof (Employee)); @@ -69,13 +69,13 @@ private: // Employee ID. }; -class GUI_Handler +class GUI_Handler { public: GUI_Handler (void) { menu(); } - ~GUI_Handler (void) - { + ~GUI_Handler (void) + { MALLOC::MEMORY_POOL &pool = shmem_manager->memory_pool(); pool.sync (); } @@ -91,7 +91,7 @@ public: ACE_ERROR ((LM_ERROR, "try again\n")); return 0; } - + int result = 0; switch (option[0]) { @@ -128,9 +128,9 @@ public: cout << "Last operation was successful!!" << endl; else cout << "Last operation failed!! " << endl; - + menu (); - + return 0; } @@ -167,9 +167,9 @@ private: if (shmem_manager->find (name, temp) == 0) { Employee *employee = (Employee *) temp; - + ACE_DEBUG ((LM_DEBUG, "The following employee was found.......\n\n")); - ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", + ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", employee->name (), employee->id ())); return 0; } @@ -180,15 +180,15 @@ private: int list_employees (void) { MALLOC_ITERATOR iterator (*shmem_manager); - + ACE_DEBUG ((LM_DEBUG, "The following employees were found.......\n\n")); - + for (void* temp = 0; - iterator.next (temp) != 0; + iterator.next (temp) != 0; iterator.advance ()) { Employee *employee = (Employee *) temp; - ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", + ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", employee->name (), employee->id ())); } return 0; @@ -201,11 +201,11 @@ private: if (shmem_manager->unbind (name, temp) == 0) { Employee *employee = (Employee *) temp; - - ACE_DEBUG ((LM_DEBUG, + + ACE_DEBUG ((LM_DEBUG, "The following employee was found and deleted.......\n\n")); - ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", + ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", employee->name (), employee->id ())); delete employee; @@ -214,7 +214,7 @@ private: ACE_DEBUG ((LM_DEBUG, "There is no employee with name %s", name)); return -1; - } + } }; void @@ -222,13 +222,13 @@ parse_args (int argc, char *argv[]) { if (argc > 1); backing_store = argv[1]; -} +} -int +int main (int argc, char *argv[]) { parse_args (argc, argv); - + shmem_manager = new MALLOC (backing_store); GUI_Handler handler; @@ -239,11 +239,15 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "closing down ....\n")); break; } - + return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex>; template class ACE_Malloc_Iterator <ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> +#pragma instantiate ACE_Malloc_Iterator <ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + |