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 | b2d8ca5a514ec1f28b4af8c2ecaa97ad5add7174 (patch) | |
tree | 1b3da514a0eb2064d0b27c62011db9492387b7dc | |
parent | 68c15412df9797b1a3ede7304dc1c120d15c9499 (diff) | |
download | ATCD-b2d8ca5a514ec1f28b4af8c2ecaa97ad5add7174.tar.gz |
added ACE_HAS_INSTANTIATION_PRAGMA support
108 files changed, 3487 insertions, 2641 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 2df2424173d..e08d97c978c 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -17,9 +17,9 @@ // Size of a VM page. size_t ACE::pagesize_ = 0; -void +void ACE::unique_name (const void *object, - LPTSTR name, + LPTSTR name, size_t length) { // The process ID will provide uniqueness between processes on the @@ -27,7 +27,7 @@ ACE::unique_name (const void *object, // uniqueness between other "live" objects in the same process. The // uniqueness of this name is therefore only valid for the life of // <object>. - TCHAR temp_name[ACE_UNIQUE_NAME_LEN]; + TCHAR temp_name[ACE_UNIQUE_NAME_LEN]; ACE_OS::sprintf (temp_name, __TEXT ("%d %d"), ACE_OS::getpid (), object); ACE_OS::strncpy (name, temp_name, length); } @@ -37,7 +37,7 @@ ACE::terminate_process (pid_t pid) { #if defined (ACE_WIN32) // Create a handle for the given process id. - ACE_HANDLE process_handle = + ACE_HANDLE process_handle = ::OpenProcess (PROCESS_TERMINATE, FALSE, // New handle is not inheritable. pid); @@ -82,7 +82,7 @@ ACE::process_active (pid_t pid) ACE_HANDLE process_handle = ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid); - if (process_handle == ACE_INVALID_HANDLE + if (process_handle == ACE_INVALID_HANDLE || process_handle == NULL) return 0; else @@ -104,14 +104,14 @@ ACE::register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags) -{ +{ #if defined (ACE_WIN32) ACE_Stdin_Args *args = 0; ACE_NEW_RETURN (args, ACE_Stdin_Args, -1); args->handler_ = eh; - args->thr_mgr_ = thr_mgr; + args->thr_mgr_ = thr_mgr; return thr_mgr->spawn (&ACE::read_adapter, args, flags); -#else +#else // Keep compilers happy. ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (thr_mgr); @@ -132,8 +132,8 @@ ACE::register_stdin_handler (ACE_Event_Handler *eh, void * ACE::read_adapter (void *args) { - ACE_Stdin_Args *stdin_adapter_args = (ACE_Stdin_Args *) args; - ACE_Thread_Control tc (stdin_adapter_args->thr_mgr_); + ACE_Stdin_Args *stdin_adapter_args = (ACE_Stdin_Args *) args; + ACE_Thread_Control tc (stdin_adapter_args->thr_mgr_); ACE_Event_Handler *this_ptr = stdin_adapter_args->handler_; ACE_HANDLE handle = ACE_STDIN; @@ -142,7 +142,7 @@ ACE::read_adapter (void *args) continue; this_ptr->handle_close (handle, ACE_Event_Handler::READ_MASK); - + delete stdin_adapter_args; return 0; } @@ -156,7 +156,7 @@ ACE::execname (const char *old_name) char *new_name; ACE_NEW_RETURN (new_name, char[ACE_OS::strlen (old_name) + - ACE_OS::strlen (".exe") + + ACE_OS::strlen (".exe") + 1], -1); char *end = new_name; end = ACE::strecpy (new_name, old_name); @@ -172,7 +172,7 @@ u_long ACE::hash_pjw (const char *str) { u_long hash = 0; - + for (const char *temp = str; *temp != 0; temp++) { hash = (hash << 4) + (*temp * 13); @@ -193,7 +193,7 @@ u_long ACE::hash_pjw (const ACE_USHORT16 *str) { u_long hash = 0; - + for (const ACE_USHORT16 *temp = str; *temp != 0; temp++) { hash = (hash << 4) + (*temp * 13); @@ -251,7 +251,7 @@ netsvc netsvc.dll libnetsvc.so (PATH will be evaluated) (LD_LIBRARY_PATH evaluated) libnetsvc.dll libnetsvc.dll libnetsvc.dll + warning -netsvc.so netsvc.so + warning libnetsvc.so +netsvc.so netsvc.so + warning libnetsvc.so ..\../libs/netsvc ..\..\libs\netsvc.dll ../../libs/netsvc.so (absolute path used) (absolute path used) @@ -260,11 +260,11 @@ netsvc.so netsvc.so + warning libnetsvc.so int ACE::ldfind (const char filename[], - char pathname[], + char pathname[], size_t maxpathnamelen) { ACE_TRACE ("ACE::ldfind"); - + char tempcopy[MAXPATHLEN]; char searchpathname[MAXPATHLEN]; char searchfilename[MAXPATHLEN]; @@ -294,7 +294,7 @@ ACE::ldfind (const char filename[], { searchpathname[0] = '\0'; ACE_OS::strcpy (searchfilename, tempcopy); - } + } else // This is an absolute path. { ACE_OS::strcpy (searchfilename, separator_ptr + 1); @@ -314,30 +314,30 @@ ACE::ldfind (const char filename[], if (ACE_OS::strcmp (s, ACE_DLL_SUFFIX) == 0) got_suffix = 1; else - ACE_ERROR ((LM_WARNING, - "Warning: improper suffix for a shared library on this platform: %s\n", + ACE_ERROR ((LM_WARNING, + "Warning: improper suffix for a shared library on this platform: %s\n", s)); } // Make sure we've got enough space in searchfilename. - if (ACE_OS::strlen (searchfilename) + - ACE_OS::strlen (ACE_DLL_PREFIX) + + if (ACE_OS::strlen (searchfilename) + + ACE_OS::strlen (ACE_DLL_PREFIX) + got_suffix ? 0 : ACE_OS::strlen (ACE_DLL_SUFFIX) >= (sizeof searchfilename / sizeof (char))) { errno = ENOMEM; return -1; - } + } // Use absolute pathname if there is one. if (ACE_OS::strlen (searchpathname) > 0) { - if (ACE_OS::strlen (searchfilename) - + ACE_OS::strlen (searchpathname) >= maxpathnamelen) + if (ACE_OS::strlen (searchfilename) + + ACE_OS::strlen (searchpathname) >= maxpathnamelen) { errno = ENOMEM; return -1; - } - else + } + else { if (ACE_DIRECTORY_SEPARATOR_CHAR != '/') // Revert to native path name separators @@ -347,16 +347,16 @@ ACE::ldfind (const char filename[], // prefix. ACE_OS::sprintf (pathname, "%s%s%s", searchpathname, - searchfilename, + searchfilename, got_suffix ? "" : ACE_DLL_SUFFIX); if (ACE_OS::access (pathname, F_OK) == 0) return 0; // Second, try matching the filename *with* adding a prefix. - ACE_OS::sprintf (pathname, "%s%s%s%s", + ACE_OS::sprintf (pathname, "%s%s%s%s", searchpathname, ACE_DLL_PREFIX, - searchfilename, + searchfilename, got_suffix ? "" : ACE_DLL_SUFFIX); if (ACE_OS::access (pathname, F_OK) == 0) return 0; @@ -365,21 +365,21 @@ ACE::ldfind (const char filename[], // Use relative filenames via LD_LIBRARY_PATH or PATH (depending on // OS platform). - else + else { char *ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH); if (ld_path != 0 && (ld_path = ACE_OS::strdup (ld_path)) != 0) { // Look at each dynamic lib directory in the search path. - char *path_entry = ACE_OS::strtok + char *path_entry = ACE_OS::strtok (ld_path, ACE_LD_SEARCH_PATH_SEPARATOR_STR); - + int result = 0; while (path_entry != 0) { - if (ACE_OS::strlen (path_entry) + if (ACE_OS::strlen (path_entry) + 1 + ACE_OS::strlen (searchfilename) >= maxpathnamelen) { errno = ENOMEM; @@ -391,7 +391,7 @@ ACE::ldfind (const char filename[], // prefix. ACE_OS::sprintf (pathname, "%s%c%s", path_entry, - ACE_DIRECTORY_SEPARATOR_CHAR, + ACE_DIRECTORY_SEPARATOR_CHAR, searchfilename); if (ACE_OS::access (pathname, F_OK) == 0) break; @@ -400,13 +400,13 @@ ACE::ldfind (const char filename[], // prefix. ACE_OS::sprintf (pathname, "%s%c%s%s", path_entry, - ACE_DIRECTORY_SEPARATOR_CHAR, + ACE_DIRECTORY_SEPARATOR_CHAR, ACE_DLL_PREFIX, searchfilename); if (ACE_OS::access (pathname, F_OK) == 0) break; - path_entry = ACE_OS::strtok + path_entry = ACE_OS::strtok (0, ACE_LD_SEARCH_PATH_SEPARATOR_STR); } @@ -436,7 +436,7 @@ ACE::basename (const char *pathname, char delim) { ACE_TRACE ("ACE::basename"); const char *temp = ::strrchr (pathname, delim); - + if (temp == 0) return pathname; else @@ -449,7 +449,7 @@ ACE::basename (const wchar_t *pathname, wchar_t delim) { ACE_TRACE ("ACE::basename"); const wchar_t *temp = ACE_OS::strrchr (pathname, delim); - + if (temp == 0) return pathname; else @@ -468,7 +468,7 @@ ACE::send_n (ACE_HANDLE handle, const void *buf, size_t len) for (bytes_written = 0; bytes_written < len; bytes_written += n) { - n = ACE::send (handle, (const char *) buf + bytes_written, + n = ACE::send (handle, (const char *) buf + bytes_written, len - bytes_written); if (n == -1) { @@ -483,9 +483,9 @@ ACE::send_n (ACE_HANDLE handle, const void *buf, size_t len) } ssize_t -ACE::send_n (ACE_HANDLE handle, - const void *buf, - size_t len, +ACE::send_n (ACE_HANDLE handle, + const void *buf, + size_t len, int flags) { ACE_TRACE ("ACE::send_n"); @@ -494,9 +494,9 @@ ACE::send_n (ACE_HANDLE handle, for (bytes_written = 0; bytes_written < len; bytes_written += n) { - n = ACE_OS::send (handle, (const char *) buf + bytes_written, + n = ACE_OS::send (handle, (const char *) buf + bytes_written, len - bytes_written, flags); - + if (n == -1) { if (errno != EWOULDBLOCK) @@ -512,9 +512,9 @@ ACE::send_n (ACE_HANDLE handle, // Receive <len> bytes into <buf> from <handle> (uses the <write> // system call on UNIX and the <WriteFile> call on Win32). -ssize_t -ACE::write_n (ACE_HANDLE handle, - const void *buf, +ssize_t +ACE::write_n (ACE_HANDLE handle, + const void *buf, size_t len) { ACE_TRACE ("ACE::write_n"); @@ -524,7 +524,7 @@ ACE::write_n (ACE_HANDLE handle, for (bytes_written = 0; bytes_written < len; bytes_written += n) { - n = ACE_OS::write (handle, (const char *) buf + bytes_written, + n = ACE_OS::write (handle, (const char *) buf + bytes_written, len - bytes_written); if (n == -1) { @@ -559,7 +559,7 @@ ACE::recv_n (ACE_HANDLE handle, void *buf, size_t len) else if (n == 0) break; } - return bytes_read; + return bytes_read; } ssize_t @@ -584,15 +584,15 @@ ACE::recv_n (ACE_HANDLE handle, void *buf, size_t len, int flags) break; } - return bytes_read; + return bytes_read; } // Receive <len> bytes into <buf> from <handle> (uses the <read> // system call on UNIX and the <ReadFile> call on Win32). -ssize_t -ACE::read_n (ACE_HANDLE handle, - void *buf, +ssize_t +ACE::read_n (ACE_HANDLE handle, + void *buf, size_t len) { ACE_TRACE ("ACE::read_n"); @@ -615,14 +615,14 @@ ACE::read_n (ACE_HANDLE handle, break; } - return bytes_read; + return bytes_read; } // Format buffer into printable format. This is useful for debugging. // Portions taken from mdump by J.P. Knight (J.P.Knight@lut.ac.uk) // Modifications by Todd Montgomery. -int +int ACE::format_hexdump (const char *buffer, int size, char *obuf, int obuf_sz) { ACE_TRACE ("ACE::format_hexdump"); @@ -641,7 +641,7 @@ ACE::format_hexdump (const char *buffer, int size, char *obuf, int obuf_sz) { int j; - for (j = 0 ; j < 16; j++) + for (j = 0 ; j < 16; j++) { c = buffer[(i << 4) + j]; ACE_OS::sprintf (obuf, "%02x ", c); @@ -658,13 +658,13 @@ ACE::format_hexdump (const char *buffer, int size, char *obuf, int obuf_sz) ACE_OS::sprintf (obuf, " %s\n", textver); - while (*obuf != '\0') + while (*obuf != '\0') obuf++; } if (size % 16) { - for (i = 0 ; i < size % 16; i++) + for (i = 0 ; i < size % 16; i++) { c = buffer[size - size % 16 + i]; ACE_OS::sprintf (obuf,"%02x ",c); @@ -677,12 +677,12 @@ ACE::format_hexdump (const char *buffer, int size, char *obuf, int obuf_sz) textver[i] = (c < 0x20 || c > 0x7e) ? '.' : c; } - for (i = size % 16; i < 16; i++) + for (i = size % 16; i < 16; i++) { ACE_OS::sprintf (obuf, " "); obuf += 3; textver[i] = ' '; - } + } textver[i] = 0; ACE_OS::sprintf (obuf, " %s\n", textver); @@ -729,7 +729,7 @@ ACE::timestamp (char date_and_time[], int date_and_timelen) ACE_OS::strncpy (date_and_time, timebuf, date_and_timelen); ACE_OS::sprintf (&date_and_time[19], ".%06d", cur_time.usec ()); #endif /* WIN32 */ - date_and_time[26] = '\0'; + date_and_time[26] = '\0'; return &date_and_time[11]; } @@ -759,7 +759,7 @@ ACE::round_to_pagesize (off_t len) return (len + (ACE::pagesize_ - 1)) & ~(ACE::pagesize_ - 1); } -ACE_HANDLE +ACE_HANDLE ACE::handle_timed_complete (ACE_HANDLE h, ACE_Time_Value *timeout) { @@ -775,15 +775,15 @@ ACE::handle_timed_complete (ACE_HANDLE h, wr_handles.set_bit (h); #if defined (ACE_WIN32) - int n = ACE_OS::select (int (h) + 1, + int n = ACE_OS::select (int (h) + 1, rd_handles, wr_handles, ex_handles, timeout); #else - int n = ACE_OS::select (int (h) + 1, + int n = ACE_OS::select (int (h) + 1, rd_handles, - wr_handles, + wr_handles, 0, timeout); #endif /* ACE_WIN32 */ @@ -823,13 +823,13 @@ ACE::handle_timed_complete (ACE_HANDLE h, // 1. The HANDLE is ready for writing or 2. recv() returned that // there are data to be read, which indicates the connection was // successfully established. - return h; + return h; } ACE_HANDLE ACE::handle_timed_open (ACE_Time_Value *timeout, LPCTSTR name, - int flags, + int flags, int perms) { ACE_TRACE ("ACE::handle_timed_open"); @@ -837,11 +837,11 @@ ACE::handle_timed_open (ACE_Time_Value *timeout, if (timeout != 0) { // Open the named pipe or file using non-blocking mode... - ACE_HANDLE handle = ACE_OS::open (name, - flags | ACE_NONBLOCK, + ACE_HANDLE handle = ACE_OS::open (name, + flags | ACE_NONBLOCK, perms); if (handle == ACE_INVALID_HANDLE - && (errno == EWOULDBLOCK + && (errno == EWOULDBLOCK && (timeout->sec () > 0 || timeout->usec () > 0))) // This expression checks if we were polling. errno = ETIMEDOUT; @@ -854,8 +854,8 @@ ACE::handle_timed_open (ACE_Time_Value *timeout, // Wait up to <timeout> amount of time to accept a connection. -int -ACE::handle_timed_accept (ACE_HANDLE listener, +int +ACE::handle_timed_accept (ACE_HANDLE listener, ACE_Time_Value *timeout, int restart) { @@ -872,8 +872,8 @@ ACE::handle_timed_accept (ACE_HANDLE listener, for (;;) { - switch (ACE_OS::select (int (listener) + 1, - rd_handle, 0, 0, + switch (ACE_OS::select (int (listener) + 1, + rd_handle, 0, 0, timeout)) { case -1: @@ -938,15 +938,15 @@ ACE::bind_port (ACE_HANDLE handle) else { upper_limit--; - + // Wrap back around when we reach the bottom. if (upper_limit <= lower_limit) upper_limit = ACE_MAX_DEFAULT_PORT; - - // See if we have already gone around once! + + // See if we have already gone around once! if (upper_limit == round_trip) { - errno = EAGAIN; + errno = EAGAIN; return -1; } } @@ -1014,7 +1014,7 @@ ACE::max_handles (void) // If NEW_LIMIT == -1 set the limit to the maximum allowable. // Otherwise, set it to be the value of NEW_LIMIT. -int +int ACE::set_handle_limit (int new_limit) { ACE_TRACE ("ACE::set_handle_limit"); @@ -1045,7 +1045,7 @@ ACE::set_flags (ACE_HANDLE handle, int flags) switch (flags) { case ACE_NONBLOCK: - // nonblocking argument (1) + // nonblocking argument (1) // blocking: (0) { u_long nonblock = 1; @@ -1061,7 +1061,7 @@ ACE::set_flags (ACE_HANDLE handle, int flags) return -1; // Turn on flags. - ACE_SET_BITS (val, flags); + ACE_SET_BITS (val, flags); if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) return -1; @@ -1081,7 +1081,7 @@ ACE::clr_flags (ACE_HANDLE handle, int flags) switch (flags) { case ACE_NONBLOCK: - // nonblocking argument (1) + // nonblocking argument (1) // blocking: (0) { u_long nonblock = 0; @@ -1097,7 +1097,7 @@ ACE::clr_flags (ACE_HANDLE handle, int flags) return -1; // Turn flags off. - ACE_CLR_BITS (val, flags); + ACE_CLR_BITS (val, flags); if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) return -1; @@ -1121,10 +1121,10 @@ ACE::map_errno (int error) } ssize_t -ACE::send (ACE_HANDLE handle, - const void *buf, - size_t n, - int flags, +ACE::send (ACE_HANDLE handle, + const void *buf, + size_t n, + int flags, const ACE_Time_Value *timeout) { if (timeout == 0) @@ -1178,9 +1178,9 @@ ACE::send (ACE_HANDLE handle, } ssize_t -ACE::send (ACE_HANDLE handle, - const void *buf, - size_t n, +ACE::send (ACE_HANDLE handle, + const void *buf, + size_t n, const ACE_Time_Value *timeout) { if (timeout == 0) @@ -1239,10 +1239,10 @@ ACE::send (ACE_HANDLE handle, } ssize_t -ACE::send_n (ACE_HANDLE handle, - const void *buf, - size_t n, - int flags, +ACE::send_n (ACE_HANDLE handle, + const void *buf, + size_t n, + int flags, const ACE_Time_Value *timeout) { size_t bytes_written; @@ -1252,7 +1252,7 @@ ACE::send_n (ACE_HANDLE handle, for (bytes_written = 0; bytes_written < n; bytes_written += i) { - i = ACE::send (handle, (char *) buf + bytes_written, + i = ACE::send (handle, (char *) buf + bytes_written, n - bytes_written, flags, timeout); if (i == -1) break; @@ -1262,10 +1262,10 @@ ACE::send_n (ACE_HANDLE handle, } ssize_t -ACE::recv (ACE_HANDLE handle, - void *buf, - size_t n, - int flags, +ACE::recv (ACE_HANDLE handle, + void *buf, + size_t n, + int flags, const ACE_Time_Value *timeout) { if (timeout == 0) @@ -1295,10 +1295,10 @@ ACE::recv (ACE_HANDLE handle, } ssize_t -ACE::recv_n (ACE_HANDLE handle, - void *buf, - size_t n, - int flags, +ACE::recv_n (ACE_HANDLE handle, + void *buf, + size_t n, + int flags, const ACE_Time_Value *timeout) { size_t bytes_received; @@ -1308,7 +1308,7 @@ ACE::recv_n (ACE_HANDLE handle, for (bytes_received = 0; bytes_received < n; bytes_received += i) { - i = ACE::recv (handle, (char *) buf + bytes_received, + i = ACE::recv (handle, (char *) buf + bytes_received, n - bytes_received, flags, timeout); if (i == -1 || i == 0) @@ -1442,7 +1442,7 @@ ACE::sock_error (int error) int ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, const char *host_name, - ACE_UINT32 host_addr, + ACE_UINT32 host_addr, ACE_HANDLE handle) { ACE_TRACE ("ACE::get_bcast_addr"); @@ -1482,19 +1482,19 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, return -1; else ACE_OS::memcpy ((char *) &ip_addr.sin_addr.s_addr, - (char *) hp->h_addr, + (char *) hp->h_addr, hp->h_length); } else { ACE_OS::memset ((void *) &ip_addr, 0, sizeof ip_addr); - ACE_OS::memcpy ((void *) &ip_addr.sin_addr, - (void*) &host_addr, + ACE_OS::memcpy ((void *) &ip_addr.sin_addr, + (void*) &host_addr, sizeof ip_addr.sin_addr); } for (int n = ifc.ifc_len / sizeof (struct ifreq); - n > 0; + n > 0; n--, ifr++) { struct sockaddr_in if_addr; @@ -1538,12 +1538,12 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, ACE_ERROR ((LM_ERROR, "%p\n", "ACE::get_bcast_addr: ioctl (get broadaddr)")); else - { + { ACE_OS::memcpy ((struct sockaddr_in *) &ip_addr, (struct sockaddr_in *) &if_req.ifr_broadaddr, sizeof if_req.ifr_broadaddr); - ACE_OS::memcpy ((void *) &host_addr, + ACE_OS::memcpy ((void *) &host_addr, (void *) &ip_addr.sin_addr, sizeof host_addr); @@ -1577,12 +1577,12 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, // put into own subroutine. perform some ioctls to retrieve ifconf // list of ifreq structs. -int -ACE::count_interfaces (ACE_HANDLE handle, +int +ACE::count_interfaces (ACE_HANDLE handle, size_t &how_many) { #if defined (sparc) && defined (SIOCGIFNUM) - if (ACE_OS::ioctl (handle, SIOCGIFNUM, (caddr_t) &how_many) == -1) + if (ACE_OS::ioctl (handle, SIOCGIFNUM, (caddr_t) &how_many) == -1) ACE_ERROR_RETURN ((LM_ERROR, "ACE::get_ip_interfaces:ioctl - SIOCGIFNUM failed"), -1); return 0; #elif defined (unix) @@ -1599,7 +1599,7 @@ ACE::count_interfaces (ACE_HANDLE handle, ifreq_size = num_ifs * sizeof (struct ifreq); p_ifs = (struct ifreq *) ACE_OS::malloc (ifreq_size); - if (!p_ifs) + if (!p_ifs) { errno = ENOMEM; return -1; @@ -1608,20 +1608,20 @@ ACE::count_interfaces (ACE_HANDLE handle, ACE_OS::memset (p_ifs, 0, ifreq_size); ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf)); ifcfg.ifc_req = p_ifs; - ifcfg.ifc_len = ifreq_size; - - if (ACE_OS::ioctl (handle, SIOCGIFCONF, (caddr_t) &ifcfg) == -1) + ifcfg.ifc_len = ifreq_size; + + if (ACE_OS::ioctl (handle, SIOCGIFCONF, (caddr_t) &ifcfg) == -1) { ACE_OS::free (ifcfg.ifc_req); ACE_ERROR_RETURN ((LM_ERROR, "count_interfaces:ioctl - SIOCGIFCONF failed"), -1); - } + } int if_count = 0, i ; // get if address out of ifreq buffers. // ioctl puts a blank-named interface to mark the end of the // returned interfaces. - for (i = 0; i < num_ifs; p_ifs++, i++) + for (i = 0; i < num_ifs; p_ifs++, i++) { if (p_ifs->ifr_name[0] == '\0') break; @@ -1659,25 +1659,25 @@ ACE::get_handle (void) // Return value in buffer for a key/name pair from the Windows // Registry up to buf_len size. -static int +static int get_reg_value (const TCHAR *key, const TCHAR *name, TCHAR *buffer, DWORD &buf_len) { - HKEY hk; + HKEY hk; DWORD buf_type; LONG rc = RegOpenKeyEx (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hk); // 1. open key that defines the interfaces used for TCP/IP? - if (rc != ERROR_SUCCESS) - // print_error_string(TEXT("RegOpenKeyEx"), rc); + if (rc != ERROR_SUCCESS) + // print_error_string(TEXT("RegOpenKeyEx"), rc); return -1; - rc = RegQueryValueEx (hk, name, 0, &buf_type, + rc = RegQueryValueEx (hk, name, 0, &buf_type, (unsigned char *) buffer, &buf_len); - if (rc != ERROR_SUCCESS) + if (rc != ERROR_SUCCESS) { // print_error_string(TEXT("RegEnumKeyEx"), rc); RegCloseKey (hk); @@ -1693,7 +1693,7 @@ get_reg_value (const TCHAR *key, // rc = 0 on success (count == number of interfaces else -1 caller is // responsible for calling delete [] on parray -int +int ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs) { @@ -1721,8 +1721,8 @@ ACE::get_ip_interfaces (size_t &count, raw_buflen)) return -1; // return buffer contains NULL delimited strings - - ACE_Tokenizer dev_names (raw_buffer); + + ACE_Tokenizer dev_names (raw_buffer); dev_names.delimiter (__TEXT('\0')); int n_interfaces = 0; @@ -1737,24 +1737,24 @@ ACE::get_ip_interfaces (size_t &count, ACE_NEW_RETURN (addrs, ACE_INET_Addr[n_interfaces], -2); count = 0; - for (int i = 0; i < n_interfaces; i++) + for (int i = 0; i < n_interfaces; i++) { - // a. construct name to access IPAddress for this interface + // a. construct name to access IPAddress for this interface ACE_TEXT_STRING ifdevkey (SVCS_KEY1); ACE_TEXT_STRING the_dev = dev_names.next (); // chop off the "\Device" and keep last name. if (the_dev.length() < 8) return -3; // Something's wrong - else + else { the_dev = the_dev.substring (8); // rest of string from offset 8 ifdevkey += the_dev; ifdevkey += TCP_PARAM_SUBKEY; - // b. extract value - if (get_reg_value (ifdevkey.rep(), IPADDR_NAME_ID, buffer, buf_len)) + // b. extract value + if (get_reg_value (ifdevkey.rep(), IPADDR_NAME_ID, buffer, buf_len)) return -4; if (ACE_OS::strcmp (buffer, INVALID_TCPIP_DEVICE_ADDR) == 0) @@ -1773,7 +1773,7 @@ ACE::get_ip_interfaces (size_t &count, ACE_HANDLE handle = get_handle(); // call specific routine as necessary - if (handle == ACE_INVALID_HANDLE) + if (handle == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE::get_ip_interfaces:open"), -1); if (ACE::count_interfaces (handle, num_ifs)) @@ -1791,19 +1791,19 @@ ACE::get_ip_interfaces (size_t &count, ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct ifreq)); auto_array_ptr<struct ifreq> p_ifs (ifs); - if (p_ifs.get() == 0) + if (p_ifs.get() == 0) { ACE_OS::close (handle); errno = ENOMEM; return -1; } - - struct ifconf ifcfg; + + struct ifconf ifcfg; ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf)); ifcfg.ifc_req = p_ifs.get (); - ifcfg.ifc_len = num_ifs * sizeof (struct ifreq); + ifcfg.ifc_len = num_ifs * sizeof (struct ifreq); - if (ACE_OS::ioctl (handle, SIOCGIFCONF, (caddr_t) &ifcfg) == -1) + if (ACE_OS::ioctl (handle, SIOCGIFCONF, (caddr_t) &ifcfg) == -1) { ACE_OS::close (handle); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "is_address_local:ioctl - SIOCGIFCONF failed"), -1); @@ -1821,7 +1821,7 @@ ACE::get_ip_interfaces (size_t &count, // note that the 3rd arg (0) says to leave the byte order (already in net // byte order from the interface structure) as is. count = 0; - for (size_t i = 0; i < num_ifs; pcur++, i++) + for (size_t i = 0; i < num_ifs; pcur++, i++) { if (pcur->ifr_addr.sa_family == AF_INET) { @@ -1830,7 +1830,7 @@ ACE::get_ip_interfaces (size_t &count, count++; } } - return 0; + return 0; #else ACE_UNUSED_ARG (count); ACE_UNUSED_ARG (addrs); @@ -1871,7 +1871,11 @@ ACE_Object_Manager_Destroyer::~ACE_Object_Manager_Destroyer () /////////////////////////////////////////////////////////////////////////////// -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class auto_array_ptr<struct ifreq>; template class auto_basic_array_ptr<struct ifreq>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate auto_array_ptr<struct ifreq> +#pragma instantiate auto_basic_array_ptr<struct ifreq> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Dump.cpp b/ace/Dump.cpp index b84c61c380c..57e8aae7ac6 100644 --- a/ace/Dump.cpp +++ b/ace/Dump.cpp @@ -24,23 +24,23 @@ ACE_Dumpable::ACE_Dumpable (const void *this_ptr) } ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable *dumper) - : dumper_ (dumper) + : dumper_ (dumper) { ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr"); } const ACE_Dumpable * ACE_Dumpable_Ptr::operator->() const -{ +{ ACE_TRACE ("ACE_Dumpable_Ptr::operator->"); - return this->dumper_; + return this->dumper_; } -void +void ACE_Dumpable_Ptr::operator= (const ACE_Dumpable *dumper) const { ACE_TRACE ("ACE_Dumpable_Ptr::operator="); - if (this->dumper_ != dumper) + if (this->dumper_ != dumper) { delete (ACE_Dumpable *) this->dumper_; ((ACE_Dumpable_Ptr *) this)->dumper_ = dumper; @@ -68,7 +68,7 @@ ACE_ODB::instance (void) return ACE_ODB::instance_; } -void +void ACE_ODB::dump_objects (void) { ACE_TRACE ("ACE_ODB::dump_objects"); @@ -83,7 +83,7 @@ ACE_ODB::dump_objects (void) // This method registers a new <dumper>. It detects // duplicates and simply overwrites them. -void +void ACE_ODB::register_object (const ACE_Dumpable *dumper) { ACE_TRACE ("ACE_ODB::register_object"); @@ -110,7 +110,7 @@ ACE_ODB::register_object (const ACE_Dumpable *dumper) this->object_table_[slot].dumper_ = dumper; } -void +void ACE_ODB::remove_object (const void *this_ptr) { ACE_TRACE ("ACE_ODB::remove_object"); @@ -131,6 +131,11 @@ ACE_ODB::remove_object (const void *this_ptr) ACE_ODB *ACE_ODB::instance_ = 0; -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) ACE_MT (template class ACE_Guard<ACE_Thread_Mutex>); -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#pragma instantiate ACE_Guard<ACE_Thread_Mutex> +#endif /* ACE_MT_SAFE */ +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Future.cpp b/ace/Future.cpp index eccf2ef6e0b..75eee48a85f 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -12,7 +12,7 @@ // Dump the state of an object. -template <class T> void +template <class T> void ACE_Future_Rep<T>::dump (void) const { ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -39,7 +39,7 @@ ACE_Future_Rep<T>::create (void) return new ACE_Future_Rep<T>(); } -template <class T> ACE_Future_Rep<T> * +template <class T> ACE_Future_Rep<T> * ACE_Future_Rep<T>::attach (ACE_Future_Rep<T>*& rep) { ACE_ASSERT (rep != 0); @@ -49,13 +49,13 @@ ACE_Future_Rep<T>::attach (ACE_Future_Rep<T>*& rep) return rep; } -template <class T> void +template <class T> void ACE_Future_Rep<T>::detach (ACE_Future_Rep<T>*& rep) { ACE_ASSERT(rep != 0); // Use value_ready_mutex_ for both condition and ref count management ACE_MT (ACE_GUARD (ACE_Thread_Mutex, r_mon, rep->value_ready_mutex_)); - + if (rep->ref_count_-- == 0) { r_mon.release (); @@ -66,17 +66,17 @@ ACE_Future_Rep<T>::detach (ACE_Future_Rep<T>*& rep) } } -template <class T> void +template <class T> void ACE_Future_Rep<T>::assign (ACE_Future_Rep<T>*& rep, ACE_Future_Rep<T>* new_rep) { ACE_ASSERT(rep != 0); ACE_ASSERT(new_rep != 0); // Use value_ready_mutex_ for both condition and ref count management ACE_MT (ACE_GUARD (ACE_Thread_Mutex, r_mon, rep->value_ready_mutex_)); - + ACE_Future_Rep<T>* old = rep; rep = new_rep; - + // detached old last for exception safety if (old->ref_count_-- == 0) { @@ -88,7 +88,7 @@ ACE_Future_Rep<T>::assign (ACE_Future_Rep<T>*& rep, ACE_Future_Rep<T>* new_rep) } } -template <class T> +template <class T> ACE_Future_Rep<T>::ACE_Future_Rep (void) : value_ (0), ref_count_ (0), @@ -96,7 +96,7 @@ ACE_Future_Rep<T>::ACE_Future_Rep (void) { } -template <class T> +template <class T> ACE_Future_Rep<T>::~ACE_Future_Rep (void) { delete this->value_; @@ -141,7 +141,7 @@ ACE_Future_Rep<T>::get (T &value, // If the value is not yet defined we must block until the // producer writes to it. - while (this->value_ == 0) + while (this->value_ == 0) // Perform a timed wait. if (this->value_ready_.wait (tv) == -1) return -1; @@ -167,12 +167,12 @@ ACE_Future_Rep<T>::operator T () // Wait ``forever.'' - while (this->value_ == 0) + while (this->value_ == 0) if (this->value_ready_.wait () == -1) // What to do in this case since we've got to indicate // failure somehow? Exceptions would be nice, but they're // not portable... - return 0; + return 0; // Destructor releases the mutex } @@ -180,7 +180,7 @@ ACE_Future_Rep<T>::operator T () return *this->value_; } -template <class T> +template <class T> ACE_Future<T>::ACE_Future (void) : future_rep_ (FUTURE_REP::create ()) { @@ -200,19 +200,19 @@ ACE_Future<T>::ACE_Future (const T &r) this->future_rep_->set (r); } -template <class T> +template <class T> ACE_Future<T>::~ACE_Future (void) { FUTURE_REP::detach (future_rep_); } -template <class T> int +template <class T> int ACE_Future<T>::operator== (const ACE_Future<T> &r) const { return r.future_rep_ == this->future_rep_; } -template <class T> int +template <class T> int ACE_Future<T>::operator!= (const ACE_Future<T> &r) const { return r.future_rep_ != this->future_rep_; @@ -227,7 +227,7 @@ ACE_Future<T>::cancel (const T &r) template <class T> int ACE_Future<T>::cancel (void) -{ +{ // If this ACE_Future is already attached to a ACE_Future_Rep, // detach it (maybe delete the ACE_Future_Rep). FUTURE_REP::assign (this->future_rep_, FUTURE_REP::create ()); @@ -235,7 +235,7 @@ ACE_Future<T>::cancel (void) } template <class T> int -ACE_Future<T>::set (const T &r) +ACE_Future<T>::set (const T &r) { // Give the pointer to the result to the ACE_Future_Rep. return this->future_rep_->set (r); @@ -257,7 +257,7 @@ ACE_Future<T>::get (T &value, ACE_Time_Value *tv) template <class T> ACE_Future<T>::operator T () { - // note that this will fail (and COREDUMP!) + // note that this will fail (and COREDUMP!) // if future_rep_ == 0 ! // // but... @@ -273,7 +273,7 @@ ACE_Future<T>::operator T () } template <class T> void -ACE_Future<T>::operator = (const ACE_Future<T> &rhs) +ACE_Future<T>::operator = (const ACE_Future<T> &rhs) { // assignment: // @@ -281,11 +281,11 @@ ACE_Future<T>::operator = (const ACE_Future<T> &rhs) // This will work if &r == this, by first increasing the ref count ACE_Future<T> &r = ( ACE_Future<T> &) rhs; - FUTURE_REP::assign (this->future_rep_, + FUTURE_REP::assign (this->future_rep_, FUTURE_REP::attach (r.future_rep_)); } -template <class T> void +template <class T> void ACE_Future<T>::dump (void) const { ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -301,7 +301,7 @@ ACE_Future<T>::operator new (size_t) return 0; } -template <class T> void +template <class T> void ACE_Future<T>::operator delete (void *) { } @@ -311,11 +311,16 @@ ACE_Future<T>::operator &() { } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // This should probably be moved elsewhere now that ACE_Atomic_Op<> // isn't used. template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +// This should probably be moved elsewhere now that ACE_Atomic_Op<> +// isn't used. +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ #endif /* ACE_FUTURE_CPP */ diff --git a/ace/Local_Name_Space.cpp b/ace/Local_Name_Space.cpp index 0ba1c5dc0f2..9cdaa126261 100644 --- a/ace/Local_Name_Space.cpp +++ b/ace/Local_Name_Space.cpp @@ -66,7 +66,7 @@ ACE_NS_String::strstr (const ACE_NS_String &s) const // They're smaller than we are... size_t len = (this->len_ - s.len_) / sizeof (ACE_USHORT16); size_t pat_len = s.len_ / sizeof (ACE_USHORT16) - 1; - + for (size_t i = 0; i <= len; i++) { size_t j; @@ -74,12 +74,12 @@ ACE_NS_String::strstr (const ACE_NS_String &s) const for (j = 0; j < pat_len; j++) if (this->rep_[i + j] != s.rep_[j]) break; - + if (j == pat_len) // Found a match! Return the index. return i; } - + return -1; } } @@ -89,7 +89,7 @@ ACE_NS_String::operator == (const ACE_NS_String &s) const { ACE_TRACE ("ACE_NS_String::operator =="); return this->len_ == s.len_ - && ACE_OS::memcmp ((void *) this->rep_, + && ACE_OS::memcmp ((void *) this->rep_, (void *) s.rep_, this->len_) == 0; } @@ -100,17 +100,17 @@ ACE_NS_String::operator != (const ACE_NS_String &s) const return !this->operator == (s); } -ACE_NS_String::ACE_NS_String (ACE_USHORT16 *dst, - const ACE_USHORT16 *src, +ACE_NS_String::ACE_NS_String (ACE_USHORT16 *dst, + const ACE_USHORT16 *src, size_t bytes) - : len_ (bytes), + : len_ (bytes), rep_ (dst) { ACE_TRACE ("ACE_NS_String::ACE_NS_String"); ACE_OS::memcpy (this->rep_, src, bytes); } -size_t +size_t ACE_NS_String::hash (void) const { return ACE::hash_pjw (this->rep_); @@ -129,7 +129,7 @@ ACE_NS_Internal::ACE_NS_Internal (ACE_NS_String &value, const char *type) int ACE_NS_Internal::operator == (const ACE_NS_Internal &s) const -{ +{ ACE_TRACE ("ACE_NS_Internal::operator =="); return this->value_ == s.value_; } @@ -148,7 +148,7 @@ ACE_NS_Internal::type (void) return this->type_; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) #if (1) template class ACE_Hash_Map_Manager<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex>; template class ACE_Hash_Map_Iterator<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex>; @@ -167,5 +167,25 @@ template class ACE_Node<ACE_Name_Binding>; template class ACE_Guard<ACE_RW_Process_Mutex>; template class ACE_Read_Guard<ACE_RW_Process_Mutex>; template class ACE_Write_Guard<ACE_RW_Process_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if (1) +#pragma instantiate ACE_Hash_Map_Manager<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Entry <ACE_NS_String, ACE_NS_Internal> +#else +#pragma instantiate ACE_Map_Manager<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry <ACE_NS_String, ACE_NS_Internal> +#endif +#pragma instantiate ACE_Unbounded_Set<ACE_Name_Binding> +#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Name_Binding> +#pragma instantiate ACE_Unbounded_Set<ACE_WString> +#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_WString> +#pragma instantiate ACE_Node<ACE_WString> +#pragma instantiate ACE_Node<ACE_Name_Binding> +#pragma instantiate ACE_Guard<ACE_RW_Process_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_RW_Process_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_RW_Process_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_LOCAL_NAME_SPACE_C */ diff --git a/ace/Local_Tokens.cpp b/ace/Local_Tokens.cpp index 374582dc70a..755ef5cb0cf 100644 --- a/ace/Local_Tokens.cpp +++ b/ace/Local_Tokens.cpp @@ -21,7 +21,7 @@ ACE_Tokens::dump (void) const reference_count_, token_name_)); ACE_DEBUG ((LM_DEBUG, "waiters_\n")); this->waiters_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_Tokens::ACE_Tokens (void) @@ -48,7 +48,7 @@ ACE_TPQ_Entry::dump (void) const { ACE_TRACE ("ACE_TPQ_Entry::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "ACE_TPQ_Entry::dump:\n" " nesting_level_ = %d\n" " client_id_ = %s\n", @@ -62,10 +62,10 @@ ACE_TPQ_Entry::dump (void) const } ACE_DEBUG ((LM_DEBUG, "ACE_TPQ_Entry::dump end.\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy, +ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy, const char *client_id) : cond_var_ (lock_), next_ (0), @@ -86,9 +86,9 @@ ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy, ACE_OS::hostname (host_name, sizeof host_name); ACE_OS::sprintf (name, - "/%s/%u/%u", - host_name, - ACE_OS::getpid (), + "/%s/%u/%u", + host_name, + ACE_OS::getpid (), ACE_Thread::self ()); this->client_id (name); @@ -159,7 +159,7 @@ ACE_TSS_TPQ_Entry::dump (void) const client_id_ == 0 ? "0" : client_id_)); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_TPQ_ENTRY::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_TSS_TPQ_Entry::ACE_TSS_TPQ_Entry (const ACE_Token_Proxy *proxy, @@ -175,7 +175,7 @@ ACE_TSS_TPQ_Entry::make_TSS_TYPE (void) const { ACE_TRACE ("ACE_TSS_TPQ_Entry::make_TSS_TYPE"); ACE_TPQ_Entry *temp; - + ACE_NEW_RETURN (temp, ACE_TPQ_Entry (this->proxy_, this->client_id_), 0); return temp; } @@ -185,7 +185,7 @@ ACE_TSS_TPQ_Entry::operator ACE_TPQ_Entry * (void) ACE_TRACE ("ACE_TSS_TPQ_Entry::operator"); return (ACE_TPQ_Entry *) (*((ACE_TSS<ACE_TPQ_Entry> *) this)); } - + // ************************************************************ // ************************************************************ // ************************************************************ @@ -202,7 +202,7 @@ ACE_TPQ_Iterator::next (ACE_TPQ_Entry *&next_item) ACE_TRACE ("ACE_TPQ_Iterator::next"); next_item = this->current_; - + return current_ != 0; } @@ -232,7 +232,7 @@ ACE_TPQ_Iterator::dump (void) const " current_ = %d\n", (long) this->current_)); ACE_DEBUG ((LM_DEBUG, "head_ and tail_\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } // ************************************************************ @@ -252,7 +252,7 @@ ACE_Token_Proxy_Queue::dump (void) const this->head_->dump (); ACE_DEBUG ((LM_DEBUG, "ACE_Token_Proxy_Queue::dump end.\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_Token_Proxy_Queue::ACE_Token_Proxy_Queue (void) @@ -320,9 +320,9 @@ ACE_Token_Proxy_Queue::dequeue (void) if (head_ == 0) return; - + ACE_TPQ_Entry *temp = this->head_; - + this->head_ = this->head_->next_; temp->next_ = 0; @@ -410,7 +410,7 @@ ACE_Mutex_Token::dump (void) const ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Tokens::dump (); ACE_DEBUG ((LM_DEBUG, "ACE_Mutex_Token::dump end.\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_Mutex_Token::ACE_Mutex_Token (const char *name) @@ -431,7 +431,7 @@ ACE_Mutex_Token::~ACE_Mutex_Token (void) ACE_TRACE ("ACE_Mutex_Token::~ACE_Mutex_Token"); } -int +int ACE_Mutex_Token::acquire (ACE_TPQ_Entry *caller, int ignore_deadlock, int notify) @@ -462,7 +462,7 @@ ACE_Mutex_Token::acquire (ACE_TPQ_Entry *caller, } // Check for deadlock. - if (!ignore_deadlock + if (!ignore_deadlock && ACE_Token_Manager::instance ()->check_deadlock (caller->proxy ()) == 1) { errno = EDEADLK; @@ -480,7 +480,7 @@ ACE_Mutex_Token::acquire (ACE_TPQ_Entry *caller, ACE_RETURN (-1); } -int +int ACE_Mutex_Token::tryacquire (ACE_TPQ_Entry *caller) { ACE_TRACE ("ACE_Mutex_Token::tryacquire"); @@ -491,7 +491,7 @@ ACE_Mutex_Token::tryacquire (ACE_TPQ_Entry *caller) // that this order is crucial too. It's resource coloring for other // threads which may be calling this same token. ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1); - + // Does _anyone_ own the token? if (this->owner () == 0) { @@ -510,7 +510,7 @@ ACE_Mutex_Token::tryacquire (ACE_TPQ_Entry *caller) { errno = EWOULDBLOCK; ACE_RETURN (-1); - } + } } int @@ -519,7 +519,7 @@ ACE_Mutex_Token::renew (ACE_TPQ_Entry *caller, { ACE_TRACE ("ACE_Mutex_Token::renew"); ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); - + // Verify that the caller is the owner. if (this->is_owner (caller->client_id ()) == 0) { @@ -583,7 +583,7 @@ ACE_Mutex_Token::release (ACE_TPQ_Entry *caller) return 0; } -int +int ACE_Mutex_Token::owners (OWNER_STACK &stack, const char *id) { @@ -592,15 +592,15 @@ ACE_Mutex_Token::owners (OWNER_STACK &stack, { stack.push (this->owner ()); // If an <id> is specified, return whether it is the owner being - // returned. + // returned. if (id != 0) return this->owner ()->equal_client_id (id); } - + return 0; } -int +int ACE_Mutex_Token::is_waiting_for (const char *id) { ACE_TRACE ("ACE_Mutex_Token::is_waiting_for"); @@ -622,7 +622,7 @@ ACE_Mutex_Token::is_waiting_for (const char *id) return 0; } -int +int ACE_Mutex_Token::is_owner (const char *id) { ACE_TRACE ("ACE_Mutex_Token::is_owner"); @@ -650,7 +650,7 @@ ACE_RW_Token::dump (void) const ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Tokens::dump (); ACE_DEBUG ((LM_DEBUG, "ACE_RW_Token::dump end.\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_RW_Token::ACE_RW_Token (const char *name) @@ -672,7 +672,7 @@ ACE_RW_Token::~ACE_RW_Token (void) ACE_TRACE ("ACE_RW_Token::~ACE_RW_Token"); } -int +int ACE_RW_Token::acquire (ACE_TPQ_Entry *caller, int ignore_deadlock, int notify) @@ -685,7 +685,7 @@ ACE_RW_Token::acquire (ACE_TPQ_Entry *caller, // that this order is crucial too. It's resource coloring for other // threads which may be calling this same token. ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1); - + if (caller->proxy ()->type () == ACE_RW_Token::WRITER) this->num_writers_++; @@ -720,7 +720,7 @@ ACE_RW_Token::acquire (ACE_TPQ_Entry *caller, // Failure code. // Check for deadlock. - if (!ignore_deadlock && + if (!ignore_deadlock && ACE_Token_Manager::instance ()->check_deadlock (caller->proxy ()) == 1) { if (caller->proxy ()->type () == ACE_RW_Token::WRITER) @@ -746,7 +746,7 @@ ACE_RW_Token::acquire (ACE_TPQ_Entry *caller, temp->call_sleep_hook (); temp = temp->next_; } - while (temp != 0 && + while (temp != 0 && temp->proxy ()->type () == ACE_RW_Token::READER); } } @@ -755,7 +755,7 @@ ACE_RW_Token::acquire (ACE_TPQ_Entry *caller, ACE_RETURN (-1); } -int +int ACE_RW_Token::tryacquire (ACE_TPQ_Entry *caller) { ACE_TRACE ("ACE_RW_Token::tryacquire"); @@ -816,7 +816,7 @@ ACE_RW_Token::renew (ACE_TPQ_Entry *caller, { ACE_TRACE ("ACE_RW_Token::renew"); ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); - + // Werify that the caller is the owner if (this->is_owner (caller->client_id ()) == 0) { @@ -861,7 +861,7 @@ ACE_RW_Token::release (ACE_TPQ_Entry *caller) ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); // Check for errors. - if ((this->owner () == 0) || + if ((this->owner () == 0) || (this->is_owner (caller->client_id ()) == 0)) { errno = EACCES; @@ -919,7 +919,7 @@ ACE_RW_Token::notify_new_owner (ACE_TPQ_Entry *old_owner) } -int +int ACE_RW_Token::owners (OWNER_STACK &stack, const char *id) { @@ -935,8 +935,8 @@ ACE_RW_Token::owners (OWNER_STACK &stack, { stack.push (this->owner ()); // If an <id> is specified, return whether it is the owner being - // returned. - if ((id != 0) && + // returned. + if ((id != 0) && (ACE_OS::strcmp (id, this->owner ()->client_id ()) == 0)) id_is_owner = 1; } @@ -955,7 +955,7 @@ ACE_RW_Token::owners (OWNER_STACK &stack, stack.push (temp); - if (!id_is_owner && (id != 0) && + if (!id_is_owner && (id != 0) && (ACE_OS::strcmp (id, temp->client_id ()) == 0)) id_is_owner = 1; } @@ -964,7 +964,7 @@ ACE_RW_Token::owners (OWNER_STACK &stack, return id_is_owner; } -int +int ACE_RW_Token::is_waiting_for (const char *id) { ACE_TRACE ("ACE_RW_Token::is_waiting_for"); @@ -987,7 +987,7 @@ ACE_RW_Token::is_waiting_for (const char *id) return 0; } -int +int ACE_RW_Token::is_owner (const char *id) { ACE_TRACE ("ACE_Mutex_Token::is_owner"); @@ -1038,7 +1038,7 @@ ACE_Token_Proxy::dump (void) const this->waiter_.dump (); ACE_DEBUG ((LM_DEBUG, "ACE_Token_Proxy::dump end.\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } const char* @@ -1104,7 +1104,7 @@ ACE_Token_Proxy::~ACE_Token_Proxy (void) ACE_Token_Manager::instance ()->release_token (token_); } -int +int ACE_Token_Proxy::open (const char *token_name, int ignore_deadlock, int debug) @@ -1139,7 +1139,7 @@ ACE_Token_Proxy::open (const char *token_name, return 0; } -int +int ACE_Token_Proxy::acquire (int notify, void (*sleep_hook)(void *), ACE_Synch_Options &options) @@ -1177,7 +1177,7 @@ ACE_Token_Proxy::acquire (int notify, case EWOULDBLOCK : if (this->debug_) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) waiting for %s, owner is %s, " "total waiters == %d\n", this->name (), @@ -1198,7 +1198,7 @@ ACE_Token_Proxy::acquire (int notify, default : waiter_->cond_var_.mutex ().release (); - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%p\n","Token Proxy acquire."), -1); } } @@ -1214,7 +1214,7 @@ ACE_Token_Proxy::acquire (int notify, return 0; } -int +int ACE_Token_Proxy::tryacquire (void (*sleep_hook)(void *)) { ACE_TRACE ("ACE_Token_Proxy::tryacquire"); @@ -1229,7 +1229,7 @@ ACE_Token_Proxy::tryacquire (void (*sleep_hook)(void *)) return this->token_->tryacquire (waiter_); } -int +int ACE_Token_Proxy::renew (int requeue_position, ACE_Synch_Options &options) { @@ -1248,11 +1248,11 @@ ACE_Token_Proxy::renew (int requeue_position, { // check for error if (errno != EWOULDBLOCK) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%p renew failed\n", "ACE_Token_Proxy"), -1); - + if (this->debug_) - ACE_DEBUG ((LM_DEBUG, "(%t) renew blocking for %s, owner is %s\n", + ACE_DEBUG ((LM_DEBUG, "(%t) renew blocking for %s, owner is %s\n", this->name (), token_->owner_id ())); @@ -1263,7 +1263,7 @@ ACE_Token_Proxy::renew (int requeue_position, // we have the token { if (this->debug_) - ACE_DEBUG ((LM_DEBUG, "(%t) renewed %s\n", + ACE_DEBUG ((LM_DEBUG, "(%t) renewed %s\n", this->name ())); waiter_->cond_var_.mutex ().release (); return 0; @@ -1306,14 +1306,14 @@ ACE_Token_Proxy::handle_options (ACE_Synch_Options &options, } if (this->debug_) - ACE_DEBUG ((LM_DEBUG, "(%t) unblocking.\n", + ACE_DEBUG ((LM_DEBUG, "(%t) unblocking.\n", this->client_id ())); cv.mutex ().release (); return 0; // operation succeeded } } -int +int ACE_Token_Proxy::release (ACE_Synch_Options &) { ACE_TRACE ("ACE_Token_Proxy::release"); @@ -1337,7 +1337,7 @@ ACE_Token_Proxy::release (ACE_Synch_Options &) else { if (this->debug_) - ACE_DEBUG ((LM_DEBUG, "(%t) released %s, owner is %s\n", + ACE_DEBUG ((LM_DEBUG, "(%t) released %s, owner is %s\n", this->name (), token_->owner_id ())); @@ -1345,14 +1345,14 @@ ACE_Token_Proxy::release (ACE_Synch_Options &) } } -int +int ACE_Token_Proxy::remove (ACE_Synch_Options &) { ACE_TRACE ("ACE_Token_Proxy::remove"); return 0; } -void +void ACE_Token_Proxy::sleep_hook (void) { ACE_TRACE ("ACE_Token_Proxy::sleep_hook"); @@ -1360,7 +1360,7 @@ ACE_Token_Proxy::sleep_hook (void) return; } -void +void ACE_Token_Proxy::token_acquired (ACE_TPQ_Entry *e) { ACE_TRACE ("ACE_Token_Proxy::token_acquired"); @@ -1378,7 +1378,7 @@ ACE_Token_Proxy::token_acquired (ACE_TPQ_Entry *e) // ************************************************************ ACE_Token_Name::ACE_Token_Name (const char *token_name) -{ +{ ACE_TRACE ("ACE_Token_Name::ACE_Token_Name"); this->name (token_name); } @@ -1402,14 +1402,21 @@ ACE_Token_Name::dump (void) const ACE_DEBUG ((LM_DEBUG, "ACE_Token_Name::dump:\n" " token_name_ = %s\n", token_name_ == 0 ? "no name" : token_name_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) #if !defined (ACE_NO_TSS_TOKENS) template class ACE_TSS <ACE_TPQ_Entry>; #endif /* ACE_NO_TSS_TOKENS */ template class ACE_Unbounded_Stack <ACE_TPQ_Entry *>; template class ACE_Node <ACE_TPQ_Entry *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if !defined (ACE_NO_TSS_TOKENS) +#pragma instantiate ACE_TSS <ACE_TPQ_Entry> +#endif /* ACE_NO_TSS_TOKENS */ +#pragma instantiate ACE_Unbounded_Stack <ACE_TPQ_Entry *> +#pragma instantiate ACE_Node <ACE_TPQ_Entry *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index fb90ea66eaa..6d03c38e362 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -179,7 +179,7 @@ ACE_Log_Msg_Manager::close (void) { // The program is exiting, so delete all ACE_Log_Msg instances. - ACE_Unbounded_Set_Iterator <ACE_Log_Msg *> i + ACE_Unbounded_Set_Iterator <ACE_Log_Msg *> i (*ACE_Log_Msg_Manager::instances_); for (ACE_Log_Msg **log_msg; @@ -211,7 +211,7 @@ ACE_Log_Msg_Manager::close (void) /* static */ #if defined (ACE_HAS_THR_C_FUNC) -extern "C" +extern "C" #endif /* ACE_HAS_THR_C_FUNC */ void ACE_TSS_cleanup (void *ptr) @@ -221,7 +221,7 @@ ACE_TSS_cleanup (void *ptr) #endif /* ACE_MT_SAFE */ /* static */ -int +int ACE_Log_Msg::exists (void) { #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) @@ -242,13 +242,13 @@ ACE_Log_Msg::exists (void) #else ACE_Log_Msg *tss_log_msg = 0; - // Get the tss_log_msg from thread-specific storage. + // Get the tss_log_msg from thread-specific storage. return key_created_ && ACE_OS::thr_getspecific (key_, (void **) &tss_log_msg) != -1 && tss_log_msg; #endif /* VXWORKS || ACE_HAS_THREAD_SPECIFIC_STORAGE */ -#else +#else return 1; #endif /* defined (ACE_MT_SAFE) */ } @@ -325,8 +325,8 @@ ACE_Log_Msg::instance (void) ACE_Log_Msg *tss_log_msg = 0; - // Get the tss_log_msg from thread-specific storage. - if (ACE_OS::thr_getspecific (key_, + // Get the tss_log_msg from thread-specific storage. + if (ACE_OS::thr_getspecific (key_, (void **) &tss_log_msg) == -1) return 0; // This should not happen! @@ -359,7 +359,7 @@ ACE_Log_Msg::instance (void) return tss_log_msg; #endif /* VXWORKS || ACE_HAS_THREAD_SPECIFIC_STORAGE */ -#else +#else // Singleton implementation. static ACE_Log_Msg log_msg; @@ -371,13 +371,13 @@ ACE_Log_Msg::instance (void) // Name of the local host. const char *ACE_Log_Msg::local_host_ = 0; -// Records the program name. +// Records the program name. const char *ACE_Log_Msg::program_name_ = 0; // Default is to use stderr. u_long ACE_Log_Msg::flags_ = ACE_Log_Msg::STDERR; -// Process id of the current process. +// Process id of the current process. pid_t ACE_Log_Msg::pid_ = -1; // Current offset of msg_[]. @@ -405,13 +405,13 @@ ACE_Log_Msg::sync (const char *prog_name) // Heap checking state will be restored when the block is left. { ACE_NO_HEAP_CHECK; - + ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name); - } + } } #endif /* VXWORKS */ - ACE_Log_Msg::pid_ = ACE_OS::getpid (); + ACE_Log_Msg::pid_ = ACE_OS::getpid (); ACE_Log_Msg::msg_off_ = 0; } @@ -456,7 +456,7 @@ ACE_Log_Msg::acquire (void) } u_long -ACE_Log_Msg::priority_mask (u_long n_mask) +ACE_Log_Msg::priority_mask (u_long n_mask) { u_long o_mask = this->priority_mask_; this->priority_mask_ = n_mask; @@ -493,7 +493,7 @@ ACE_Log_Msg::ACE_Log_Msg (void) tracing_enabled_ (1), // On by default? thr_state_ (0), priority_mask_ (LM_SHUTDOWN // By default, all priorities are enabled. - | LM_TRACE + | LM_TRACE | LM_DEBUG | LM_INFO | LM_NOTICE @@ -515,17 +515,17 @@ ACE_Log_Msg::~ACE_Log_Msg (void) // when the last thread in the program exits. #if !defined (VXWORKS) && defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, *ACE_Log_Msg_Manager::get_lock ())); - + // If this is the last instance then cleanup. if (ACE_Log_Msg_Manager::remove (this) == 0) { - if (ACE_Log_Msg::program_name_) + if (ACE_Log_Msg::program_name_) { ACE_OS::free ((void *) ACE_Log_Msg::program_name_); ACE_Log_Msg::program_name_ = 0; } - if (ACE_Log_Msg::local_host_) + if (ACE_Log_Msg::local_host_) { ACE_OS::free ((void *) ACE_Log_Msg::local_host_); ACE_Log_Msg::local_host_ = 0; @@ -537,8 +537,8 @@ ACE_Log_Msg::~ACE_Log_Msg (void) // Open the sender-side of the Message ACE_Queue. int -ACE_Log_Msg::open (const char *prog_name, - u_long flags, +ACE_Log_Msg::open (const char *prog_name, + u_long flags, LPCTSTR logger_key) { ACE_TRACE ("ACE_Log_Msg::open"); @@ -556,7 +556,7 @@ ACE_Log_Msg::open (const char *prog_name, // Stop heap checking, block will be freed by the ACE_Object_Manager. { ACE_NO_HEAP_CHECK; - + ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name); } } @@ -567,7 +567,7 @@ ACE_Log_Msg::open (const char *prog_name, // Note that if we fail to open the message queue the default action // is to use stderr (set via static initialization in the // ACE_Log_Msg.C file). - + if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)) { if (logger_key == 0) @@ -592,8 +592,8 @@ ACE_Log_Msg::open (const char *prog_name, ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER); } - // Remember, ACE_Log_Msg::STDERR bit is on by default... - if (status != -1 + // Remember, ACE_Log_Msg::STDERR bit is on by default... + if (status != -1 && ACE_BIT_ENABLED (flags, ACE_Log_Msg::STDERR) == 0) ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR); @@ -633,16 +633,16 @@ ACE_Log_Msg::open (const char *prog_name, // 't': print thread id (1 if single-threaded) // 'u': print as unsigned int // 'X', 'x': print as a hex number -// '%': format a single percent sign, '%' +// '%': format a single percent sign, '%' ssize_t -ACE_Log_Msg::log (ACE_Log_Priority log_priority, +ACE_Log_Msg::log (ACE_Log_Priority log_priority, const char *format_str, ...) -{ +{ ACE_TRACE ("ACE_Log_Msg::log"); - // Start of variable args section. - va_list argp; + // Start of variable args section. + va_list argp; va_start (argp, format_str); @@ -655,11 +655,11 @@ ACE_Log_Msg::log (ACE_Log_Priority log_priority, ssize_t ACE_Log_Msg::log (const char *format_str, - ACE_Log_Priority log_priority, + ACE_Log_Priority log_priority, va_list argp) -{ +{ ACE_TRACE ("ACE_Log_Msg::log"); - // External decls. + // External decls. extern int sys_nerr; typedef void (*PTF)(...); @@ -670,7 +670,7 @@ ACE_Log_Msg::log (const char *format_str, if (ACE_BIT_DISABLED (this->priority_mask_, log_priority)) return 0; - ACE_Log_Record log_record (log_priority, + ACE_Log_Record log_record (log_priority, ACE_OS::gettimeofday (), this->getpid ()); char *bp = this->msg (); @@ -685,7 +685,7 @@ ACE_Log_Msg::log (const char *format_str, if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE)) { - // Prepend the program name onto this message + // Prepend the program name onto this message if (ACE_Log_Msg::program_name_ != 0) { @@ -699,43 +699,43 @@ ACE_Log_Msg::log (const char *format_str, while (*format != '\0') { // Copy input to output until we encounter a %, however a - // % followed by another % is not a format specification. + // % followed by another % is not a format specification. if (*format != '%') *bp++ = *format++; else if (format[1] == '%') // An "escaped" '%' (just print one '%'). { - *bp++ = *format++; // Store first % - format++; // but skip second % + *bp++ = *format++; // Store first % + format++; // but skip second % } else { - char c; // high use character - char *fp; // local format pointer - int wpc; // width/precision cnt + char c; // high use character + char *fp; // local format pointer + int wpc; // width/precision cnt const int CONTINUE = 0; - const int SKIP_SPRINTF = -1; // We must skip the sprintf phase - const int SKIP_NUL_LOCATE = -2; // Skip locating the NUL character - int type = CONTINUE; // conversion type - int w[2]; // width/precision vals + const int SKIP_SPRINTF = -1; // We must skip the sprintf phase + const int SKIP_NUL_LOCATE = -2; // Skip locating the NUL character + int type = CONTINUE; // conversion type + int w[2]; // width/precision vals // % starts a format specification that ends with one of // "arnPpSsdciIouxXfFeEgG". An optional width and/or precision // (indicated by an "*") may be encountered prior to the // nend of the specification, each consumes an int arg. - // A call to sprintf() does the actual conversion. + // A call to sprintf() does the actual conversion. - fp = format++; // Remember beginning of format. - wpc = 0; // Assume no width/precision seen. + fp = format++; // Remember beginning of format. + wpc = 0; // Assume no width/precision seen. while (type == CONTINUE) { switch (*format++) { - case 'a': // Abort program after handling all of format string. + case 'a': // Abort program after handling all of format string. type = SKIP_SPRINTF; - abort_prog = 1; - exit_value = va_arg (argp, int); + abort_prog = 1; + exit_value = va_arg (argp, int); ACE_OS::sprintf (bp, ""); // Make sure to NUL-terminate this... break; case 'l': @@ -750,28 +750,28 @@ ACE_Log_Msg::log (const char *format_str, type = SKIP_SPRINTF; break; } - case 'n': // Print the name of the program. + case 'n': // Print the name of the program. type = SKIP_SPRINTF; // @@ UNICODE - ACE_OS::strcpy (bp, ACE_Log_Msg::program_name_ ? + ACE_OS::strcpy (bp, ACE_Log_Msg::program_name_ ? ACE_Log_Msg::program_name_ : "<unknown>"); break; case 'P': // Format the current process id. type = SKIP_SPRINTF; ACE_OS::sprintf (bp, "%d", this->getpid ()); break; - case 'p': // Format the string assocated with the value of errno. + case 'p': // Format the string assocated with the value of errno. { type = SKIP_SPRINTF; errno = ACE::map_errno (this->errnum ()); if (errno >= 0 && errno < sys_nerr) - ACE_OS::sprintf (bp, "%s: %s", + ACE_OS::sprintf (bp, "%s: %s", va_arg (argp, char *), strerror (errno)); else { -#if defined (ACE_WIN32) +#if defined (ACE_WIN32) LPTSTR lpMsgBuf = 0; - + ::FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, errno, @@ -789,12 +789,12 @@ ACE_Log_Msg::log (const char *format_str, if (lpMsgBuf == 0) { const char *message = ACE::sock_error (errno); - ACE_OS::sprintf (bp, "%s: %s", + ACE_OS::sprintf (bp, "%s: %s", va_arg (argp, const char *), message); } else { - ACE_OS::sprintf (bp, "%s: %s", + ACE_OS::sprintf (bp, "%s: %s", va_arg (argp, char *), lpMsgBuf); // Free the buffer. ::LocalFree (lpMsgBuf); @@ -802,7 +802,7 @@ ACE_Log_Msg::log (const char *format_str, #else ACE_OS::sprintf (bp, "%s: <unknown error> = %d", va_arg (argp, char *), errno); -#endif /* ACE_WIN32 */ +#endif /* ACE_WIN32 */ } break; } @@ -820,18 +820,18 @@ ACE_Log_Msg::log (const char *format_str, *bp = '\0'; break; - case 'r': // Run (invoke) this subroutine. + case 'r': // Run (invoke) this subroutine. { int osave = ACE_Log_Msg::msg_off_; - + if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT)) *bp++ = '{'; ACE_Log_Msg::msg_off_ = bp - this->msg_; - + type = SKIP_SPRINTF; - (*va_arg (argp, PTF))(); + (*va_arg (argp, PTF))(); - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT)) + if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT)) { bp += ACE_OS::strlen (bp); *bp++ = '}'; @@ -841,7 +841,7 @@ ACE_Log_Msg::log (const char *format_str, ACE_Log_Msg::msg_off_ = osave; break; } - case 'S': // format the string associated with this signal number. + case 'S': // format the string associated with this signal number. { int sig = va_arg (argp, int); type = SKIP_SPRINTF; @@ -859,12 +859,12 @@ ACE_Log_Msg::log (const char *format_str, { type = SKIP_SPRINTF; char day_and_time[35]; - ACE_OS::sprintf (bp, "%s", - ACE::timestamp (day_and_time, + ACE_OS::sprintf (bp, "%s", + ACE::timestamp (day_and_time, sizeof day_and_time)); - break; + break; } - case 't': // Format thread id. + case 't': // Format thread id. type = SKIP_SPRINTF; #if defined (ACE_WIN32) ACE_OS::sprintf (bp, "%u", ACE_Thread::self ()); @@ -875,31 +875,31 @@ ACE_Log_Msg::log (const char *format_str, #endif /* ACE_WIN32 */ break; case 's': - type = 1 + wpc; // 1, 2, 3 + type = 1 + wpc; // 1, 2, 3 break; case 'W': // @@ UNICODE - case 'd': case 'c': case 'i': case 'o': - case 'u': case 'x': case 'X': - type = 4 + wpc; // 4, 5, 6 + case 'd': case 'c': case 'i': case 'o': + case 'u': case 'x': case 'X': + type = 4 + wpc; // 4, 5, 6 break; case 'F': case 'f': case 'e': case 'E': case 'g': case 'G': - type = 7 + wpc; // 7, 8, 9 + type = 7 + wpc; // 7, 8, 9 break; - case '*': // consume width/precision + case '*': // consume width/precision w[wpc++] = va_arg (argp, int); break; default: - // ? + // ? break; } } if (type != SKIP_SPRINTF) { - c = *format; // Remember char before we overwrite. - *format = 0; // Overwrite, terminating format. + c = *format; // Remember char before we overwrite. + *format = 0; // Overwrite, terminating format. switch (type) { @@ -935,11 +935,11 @@ ACE_Log_Msg::log (const char *format_str, ACE_OS::sprintf (bp, fp, w[0], w[1], va_arg (argp, double)); break; } - *format = c; // Restore char we overwrote. + *format = c; // Restore char we overwrote. } if (type != SKIP_NUL_LOCATE) - while (*bp != '\0') // Locate end of bp. + while (*bp != '\0') // Locate end of bp. bp++; } } @@ -965,22 +965,22 @@ ACE_Log_Msg::log (const char *format_str, // Make sure that the lock is held during all this. ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_Log_Msg_Manager::get_lock (), -1)); - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR) + if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR) && abort_prog == 0) // We'll get this further down. log_record.print (ACE_Log_Msg::local_host_, ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE), stderr); if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER)) { - ACE_Str_Buf log_msg ((void *) &log_record, + ACE_Str_Buf log_msg ((void *) &log_record, int (log_record.length ())); #if defined (ACE_HAS_STREAM_PIPES) - result = message_queue_.send (int (log_record.type ()), + result = message_queue_.send (int (log_record.type ()), &log_msg); #elif !defined (ACE_WIN32) result = message_queue_.send (log_msg); #else - result = message_queue_.send ((const ACE_Str_Buf *) &log_msg, + result = message_queue_.send ((const ACE_Str_Buf *) &log_msg, (const ACE_Str_Buf *) 0); #endif /* ACE_HAS_STREAM_PIPES */ } @@ -1012,9 +1012,9 @@ ACE_Log_Msg::log (const char *format_str, // Calls log to do the actual print, but formats first. -int -ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, - const char *buffer, +int +ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, + const char *buffer, int size, const char *text) { @@ -1043,10 +1043,10 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, } void -ACE_Log_Msg::set (const char *filename, +ACE_Log_Msg::set (const char *filename, int line, - int status, - int err, + int status, + int err, int rs, ostream *os) { @@ -1086,36 +1086,36 @@ ACE_Log_Msg::dump (void) const message_queue_.dump (); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) ACE_Log_Msg_Manager::get_lock ()->dump (); - // Synchronize output operations. + // Synchronize output operations. #endif /* ACE_MT_SAFE */ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -void +void ACE_Log_Msg::op_status (int status) { this->status_ = status; } -int +int ACE_Log_Msg::op_status (void) { return this->status_; } -void +void ACE_Log_Msg::restart (int r) { this->restart_ = r; } -int +int ACE_Log_Msg::restart (void) { return this->restart_; } -int +int ACE_Log_Msg::errnum (void) { return this->errnum_; @@ -1127,7 +1127,7 @@ ACE_Log_Msg::errnum (int e) this->errnum_ = e; } -int +int ACE_Log_Msg::linenum (void) { return this->linenum_; @@ -1139,73 +1139,73 @@ ACE_Log_Msg::linenum (int l) this->linenum_ = l; } -int -ACE_Log_Msg::inc (void) -{ - return this->trace_depth_++; +int +ACE_Log_Msg::inc (void) +{ + return this->trace_depth_++; } -int -ACE_Log_Msg::dec (void) -{ - return --this->trace_depth_; +int +ACE_Log_Msg::dec (void) +{ + return --this->trace_depth_; } -int -ACE_Log_Msg::trace_active (void) -{ - return this->trace_active_; +int +ACE_Log_Msg::trace_active (void) +{ + return this->trace_active_; } -void -ACE_Log_Msg::trace_active (int value) -{ - this->trace_active_ = value; +void +ACE_Log_Msg::trace_active (int value) +{ + this->trace_active_ = value; } ACE_Thread_State * -ACE_Log_Msg::thr_state (void) -{ - return this->thr_state_; +ACE_Log_Msg::thr_state (void) +{ + return this->thr_state_; } -void +void ACE_Log_Msg::thr_state (ACE_Thread_State *ts) -{ - this->thr_state_ = ts; +{ + this->thr_state_ = ts; } ACE_hthread_t * -ACE_Log_Msg::thr_handle (void) -{ - return this->thr_handle_; +ACE_Log_Msg::thr_handle (void) +{ + return this->thr_handle_; } -void +void ACE_Log_Msg::thr_handle (ACE_hthread_t *th) -{ - this->thr_handle_ = th; +{ + this->thr_handle_ = th; } // Enable the tracing facility on a per-thread basis. -void -ACE_Log_Msg::start_tracing (void) -{ +void +ACE_Log_Msg::start_tracing (void) +{ this->tracing_enabled_ = 1; } // Disable the tracing facility on a per-thread basis. -void -ACE_Log_Msg::stop_tracing (void) -{ - this->tracing_enabled_ = 0; +void +ACE_Log_Msg::stop_tracing (void) +{ + this->tracing_enabled_ = 0; } int ACE_Log_Msg::tracing_enabled (void) -{ +{ return this->tracing_enabled_; } @@ -1218,7 +1218,7 @@ ACE_Log_Msg::file (void) void ACE_Log_Msg::file (const char *s) { - ACE_OS::strncpy (this->file_, s, + ACE_OS::strncpy (this->file_, s, (sizeof this->file_ / sizeof (char))); } @@ -1231,7 +1231,7 @@ ACE_Log_Msg::msg (void) void ACE_Log_Msg::msg (char *m) { - ACE_OS::strncpy (this->msg_, m, + ACE_OS::strncpy (this->msg_, m, (sizeof this->msg_ / sizeof (char))); } @@ -1283,9 +1283,14 @@ ACE_Log_Msg::getpid (void) const } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Node<ACE_Log_Msg *>; template class ACE_Unbounded_Set<ACE_Log_Msg *>; template class ACE_Unbounded_Set_Iterator<ACE_Log_Msg *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Node<ACE_Log_Msg *> +#pragma instantiate ACE_Unbounded_Set<ACE_Log_Msg *> +#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Log_Msg *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Malloc.cpp b/ace/Malloc.cpp index 74d6fb4b8ee..715e9b539a1 100644 --- a/ace/Malloc.cpp +++ b/ace/Malloc.cpp @@ -37,10 +37,10 @@ ACE_Name_Node::ACE_Name_Node (void) ACE_TRACE ("ACE_Name_Node::ACE_Name_Node"); } -ACE_Name_Node::ACE_Name_Node (const char *name, - void *ptr, +ACE_Name_Node::ACE_Name_Node (const char *name, + void *ptr, ACE_Name_Node *next) - : pointer_ (ptr), + : pointer_ (ptr), next_ (next) { ACE_TRACE ("ACE_Name_Node::ACE_Name_Node"); @@ -51,7 +51,7 @@ void ACE_Name_Node::dump (void) const { ACE_TRACE ("ACE_Name_Node"); - + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "pointer = %x", this->pointer_)); ACE_DEBUG ((LM_DEBUG, "\nnext_ = %x", this->next_)); @@ -120,9 +120,9 @@ ACE_Allocator::~ACE_Allocator (void) #if defined (ACE_MALLOC_STATS) ACE_Malloc_Stats::ACE_Malloc_Stats (void) - : nblocks_ (0), - nchunks_ (0), - ninuse_ (0) + : nblocks_ (0), + nchunks_ (0), + ninuse_ (0) { ACE_TRACE ("ACE_Malloc_Stats::ACE_Malloc_Stats"); } @@ -144,9 +144,12 @@ ACE_Malloc_Stats::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_PROCESS_MUTEX, int>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_PROCESS_MUTEX, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_MALLOC_STATS */ #endif /* ACE_MALLOC_C */ diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp index e29561e55a8..50d4bea84e7 100644 --- a/ace/Message_Block.cpp +++ b/ace/Message_Block.cpp @@ -66,7 +66,7 @@ ACE_Data_Block::dump (void) const { ACE_TRACE ("ACE_Data_Block::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "-----( Data Block )-----\n" "type_ = %d\n" "cur_size_ = %u\n" @@ -76,10 +76,10 @@ ACE_Data_Block::dump (void) const "locking_strategy_ = %u\n" "reference_count_ = %u\n" "---------------------------\n", - this->type_, - this->cur_size_, + this->type_, + this->cur_size_, this->max_size_, - this->flags_, + this->flags_, this->base_, this->locking_strategy_, this->reference_count_)); @@ -92,20 +92,20 @@ ACE_Message_Block::dump (void) const { ACE_TRACE ("ACE_Message_Block::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "-----( Message Block )-----\n" "priority_ = %d\n" "next_ = %u\n" "prev_ = %u\n" - "cont_ = %u\n" + "cont_ = %u\n" "rd_ptr_ = %u\n" "wr_ptr_ = %u\n" "---------------------------\n", - this->priority_, - this->next_, + this->priority_, + this->next_, this->prev_, this->cont_, - this->rd_ptr_, + this->rd_ptr_, this->wr_ptr_)); this->data_block ()->dump (); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); @@ -118,12 +118,12 @@ ACE_Data_Block::size (size_t length) if (length <= this->max_size_) this->cur_size_ = length; - else + else { // We need to resize! char *buf; - ACE_ALLOCATOR_RETURN (buf, - (char *) this->allocator_strategy_->malloc (length), + ACE_ALLOCATOR_RETURN (buf, + (char *) this->allocator_strategy_->malloc (length), -1); ACE_OS::memcpy (buf, this->base_, this->cur_size_); @@ -180,7 +180,7 @@ ACE_Data_Block::ACE_Data_Block (void) ACE_Data_Block::ACE_Data_Block (size_t size, ACE_Message_Block::ACE_Message_Type msg_type, - const char *msg_data, + const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, ACE_Message_Block::Message_Flags flags) @@ -201,7 +201,7 @@ ACE_Data_Block::ACE_Data_Block (size_t size, ACE_ALLOCATOR (this->allocator_strategy_, ACE_Allocator::instance ()); if (msg_data == 0) - ACE_ALLOCATOR (this->base_, + ACE_ALLOCATOR (this->base_, (char *) this->allocator_strategy_->malloc (size)); else this->base_ = (char *) msg_data; @@ -242,19 +242,19 @@ ACE_Message_Block::ACE_Message_Block (void) ACE_Message_Block::ACE_Message_Block (size_t size, ACE_Message_Type msg_type, - ACE_Message_Block *msg_cont, - const char *msg_data, + ACE_Message_Block *msg_cont, + const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, u_long priority) { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); - if (this->init_i (size, - msg_type, - msg_cont, - msg_data, - allocator_strategy, + if (this->init_i (size, + msg_type, + msg_cont, + msg_data, + allocator_strategy, locking_strategy, msg_data ? ACE_Message_Block::DONT_DELETE : 0, priority, @@ -263,9 +263,9 @@ ACE_Message_Block::ACE_Message_Block (size_t size, } int -ACE_Message_Block::init (size_t size, - ACE_Message_Type msg_type, - ACE_Message_Block *msg_cont, +ACE_Message_Block::init (size_t size, + ACE_Message_Type msg_type, + ACE_Message_Block *msg_cont, const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, @@ -273,11 +273,11 @@ ACE_Message_Block::init (size_t size, { ACE_TRACE ("ACE_Message_Block::init"); - return this->init_i (size, - msg_type, - msg_cont, + return this->init_i (size, + msg_type, + msg_cont, msg_data, - allocator_strategy, + allocator_strategy, locking_strategy, msg_data ? ACE_Message_Block::DONT_DELETE : 0, priority, @@ -302,9 +302,9 @@ ACE_Message_Block::init (const char *data, 0); // data block } -ACE_Message_Block::ACE_Message_Block (size_t size, - ACE_Message_Type msg_type, - ACE_Message_Block *msg_cont, +ACE_Message_Block::ACE_Message_Block (size_t size, + ACE_Message_Type msg_type, + ACE_Message_Block *msg_cont, const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, @@ -314,11 +314,11 @@ ACE_Message_Block::ACE_Message_Block (size_t size, { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); - if (this->init_i (size, - msg_type, - msg_cont, + if (this->init_i (size, + msg_type, + msg_cont, msg_data, - allocator_strategy, + allocator_strategy, locking_strategy, flags, priority, @@ -329,7 +329,7 @@ ACE_Message_Block::ACE_Message_Block (size_t size, ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block) { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); - + if (this->init_i (0, // size MB_NORMAL, // type 0, // cont @@ -343,9 +343,9 @@ ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block) } int -ACE_Message_Block::init_i (size_t size, - ACE_Message_Type msg_type, - ACE_Message_Block *msg_cont, +ACE_Message_Block::init_i (size_t size, + ACE_Message_Type msg_type, + ACE_Message_Block *msg_cont, const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, @@ -397,18 +397,18 @@ ACE_Data_Block * ACE_Data_Block::release_i (void) { ACE_TRACE ("ACE_Data_Block::release_i"); - + ACE_ASSERT (this->reference_count_ > 0); - + ACE_Data_Block *result = 0; // decrement reference count this->reference_count_--; - + if (this->reference_count_ == 0) // this will cause deletion of this result = 0; - else + else result = this; return result; @@ -445,60 +445,60 @@ ACE_Data_Block::release (ACE_Lock *lock) if (lock_to_be_used != 0) { ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock_to_be_used, 0); - + result = this->release_i (); } else result = this->release_i (); - + // We must delete this outside the scope of the locking_strategy_ // since otherwise we'd be trying to "release" through a deleted // pointer! if (result == 0) delete this; - return result; + return result; } ACE_Message_Block * ACE_Message_Block::release (void) { ACE_TRACE ("ACE_Message_Block::release"); - + ACE_Message_Block *result = 0; ACE_Lock *lock = 0; - + // Do we have a valid data block if (this->data_block ()) { // Grab the lock that belongs to my data block lock = this->data_block ()->locking_strategy (); - + // if we have a lock if (lock != 0) { // One guard for all - ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0); - + ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0); + // Call non-guarded release with <lock> result = this->release_i (lock); } // This is the case when we have a valid data block but no lock else - // Call non-guarded release with no lock - result = this->release_i (0); + // Call non-guarded release with no lock + result = this->release_i (0); } else // This is the case when we don't even have a valid data block result = this->release_i (0); - + return result; } ACE_Message_Block * ACE_Message_Block::release_i (ACE_Lock *lock) { - ACE_TRACE ("ACE_Message_Block::release_i"); + ACE_TRACE ("ACE_Message_Block::release_i"); // Free up all the continuation messages. if (this->cont_) @@ -512,7 +512,7 @@ ACE_Message_Block::release_i (ACE_Lock *lock) this->data_block ()->release (lock); this->data_block_ = 0; } - + // We will now commit suicide: this object *must* have come from the heap delete this; @@ -542,7 +542,7 @@ ACE_Message_Block::~ACE_Message_Block (void) } ACE_Data_Block * -ACE_Data_Block::duplicate (void) +ACE_Data_Block::duplicate (void) { ACE_TRACE ("ACE_Data_Block::duplicate"); @@ -570,7 +570,7 @@ ACE_Message_Block::duplicate (void) const // Create a new <ACE_Message_Block> that contains unique copies of // the message block fields, but a reference counted duplicate of // the <ACE_Data_Block>. - ACE_NEW_RETURN (nb, + ACE_NEW_RETURN (nb, ACE_Message_Block (0, // size ACE_Message_Type (0), // type 0, // cont @@ -627,12 +627,12 @@ ACE_Data_Block::clone (ACE_Message_Block::Message_Flags mask) const // You always want to clear this one to prevent memory leaks but you // might add some others later. - const ACE_Message_Block::Message_Flags always_clear = - ACE_Message_Block::DONT_DELETE; + const ACE_Message_Block::Message_Flags always_clear = + ACE_Message_Block::DONT_DELETE; ACE_Data_Block *nb; - ACE_NEW_RETURN (nb, + ACE_NEW_RETURN (nb, ACE_Data_Block (this->max_size_, // size this->type_, // type 0, // data @@ -653,16 +653,16 @@ ACE_Message_Block * ACE_Message_Block::clone (Message_Flags mask) const { ACE_TRACE ("ACE_Message_Block::clone"); - + // Get a pointer to a "cloned" <ACE_Data_Block> (will copy the // values rather than increment the reference count). ACE_Data_Block *db = this->data_block ()->clone (mask); - + if (db == 0) return 0; - ACE_Message_Block *nb = + ACE_Message_Block *nb = new ACE_Message_Block (0, // size ACE_Message_Type (0), // type 0, // cont @@ -677,14 +677,14 @@ ACE_Message_Block::clone (Message_Flags mask) const db->release (); return 0; } - + // Set the read and write pointers in the new <Message_Block> to the // same relative offset as in the existing <Message_Block>. nb->rd_ptr (this->rd_ptr_ - this->data_block ()->base ()); nb->wr_ptr (this->wr_ptr_ - this->data_block ()->base ()); // Clone all the continuation messages if necessary. - if (nb->cont_ != 0 + if (nb->cont_ != 0 && (nb->cont_ = nb->cont_->clone (mask)) == 0) { nb->release (); @@ -701,11 +701,19 @@ ACE_Message_Block::operator= (const ACE_Message_Block &) return *this; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // These specializations aren't needed for the ACE library because // Service_Config.cpp has them: // // template class ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex>; // template class ACE_Allocator_Adapter <ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> >; template class ACE_Guard<ACE_Lock>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +// These specializations aren't needed for the ACE library because +// Service_Config.cpp has them: +// +// #pragma instantiate ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> +// #pragma instantiate ACE_Allocator_Adapter <ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> > +#pragma instantiate ACE_Guard<ACE_Lock> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index 34e8f93fba8..56130bd3a37 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -29,7 +29,7 @@ ACE_STATIC_SVC_DEFINE (ACE_Naming_Context, ACE_STATIC_SVC_REQUIRE (ACE_Naming_Context) int -ACE_Naming_Context::info (char **strp, +ACE_Naming_Context::info (char **strp, size_t length) const { ACE_TRACE ("ACE_Naming_Context::info"); @@ -52,13 +52,13 @@ ACE_Naming_Context::local (void) ACE_TRACE ("ACE_Naming_Context::local"); return ACE_OS::strcmp (this->netnameserver_host_, "localhost") == 0 || ACE_OS::strcmp (this->netnameserver_host_, this->hostname_) == 0; -} +} int ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite) { ACE_TRACE ("ACE_Naming_Context::open"); - ACE_OS::hostname (this->hostname_, + ACE_OS::hostname (this->hostname_, (sizeof this->hostname_ / sizeof (char))); this->netnameserver_host_ = this->name_options_->nameserver_host (); @@ -69,7 +69,7 @@ ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite) #if (defined (ACE_WIN32) && defined (UNICODE)) // This only works on Win32 platforms when UNICODE is turned on - + if (this->name_options_->use_registry ()) // Use ACE_Registry ACE_NEW_RETURN (this->name_space_, ACE_Registry_Name_Space (this->name_options_), -1); @@ -78,7 +78,7 @@ ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite) if (scope_in == ACE_Naming_Context::NET_LOCAL && this->local () == 0) { // Use NET_LOCAL name space, set up connection with remote server. - ACE_NEW_RETURN (this->name_space_, + ACE_NEW_RETURN (this->name_space_, ACE_Remote_Name_Space (this->netnameserver_host_, this->netnameserver_port_), -1); @@ -90,9 +90,9 @@ ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite) else ACE_NEW_RETURN (this->name_space_, LOCAL_NAME_SPACE (scope_in, this->name_options_), -1); } - + if (ACE_LOG_MSG->op_status () != 0 || this->name_space_ == 0) - ACE_ERROR_RETURN ((LM_ERROR, "NAME_SPACE::NAME_SPACE\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "NAME_SPACE::NAME_SPACE\n"), -1); return 0; } @@ -138,44 +138,44 @@ ACE_Naming_Context::name_options (void) return this->name_options_; } -int -ACE_Naming_Context::bind (const ACE_WString &name_in, - const ACE_WString &value_in, +int +ACE_Naming_Context::bind (const ACE_WString &name_in, + const ACE_WString &value_in, const char *type_in) { ACE_TRACE ("ACE_Naming_Context::bind"); return this->name_space_->bind (name_in, value_in, type_in); } -int -ACE_Naming_Context::bind (const char *name_in, - const char *value_in, +int +ACE_Naming_Context::bind (const char *name_in, + const char *value_in, const char *type_in) { ACE_TRACE ("ACE_Naming_Context::bind"); return this->bind (ACE_WString (name_in), ACE_WString (value_in), type_in); } -int -ACE_Naming_Context::rebind (const ACE_WString &name_in, - const ACE_WString &value_in, +int +ACE_Naming_Context::rebind (const ACE_WString &name_in, + const ACE_WString &value_in, const char *type_in) { ACE_TRACE ("ACE_Naming_Context::rebind"); return this->name_space_->rebind (name_in, value_in, type_in); } -int -ACE_Naming_Context::rebind (const char *name_in, - const char *value_in, +int +ACE_Naming_Context::rebind (const char *name_in, + const char *value_in, const char *type_in) { ACE_TRACE ("ACE_Naming_Context::rebind"); return rebind (ACE_WString (name_in), ACE_WString (value_in), type_in); } -int -ACE_Naming_Context::resolve (const ACE_WString &name_in, +int +ACE_Naming_Context::resolve (const ACE_WString &name_in, ACE_WString &value_out, char *&type_out) { @@ -183,8 +183,8 @@ ACE_Naming_Context::resolve (const ACE_WString &name_in, return this->name_space_->resolve (name_in, value_out, type_out); } -int -ACE_Naming_Context::resolve (const char *name_in, +int +ACE_Naming_Context::resolve (const char *name_in, ACE_WString &value_out, char *&type_out) { @@ -192,9 +192,9 @@ ACE_Naming_Context::resolve (const char *name_in, return this->resolve (ACE_WString (name_in), value_out, type_out); } -int -ACE_Naming_Context::resolve (const char *name_in, - char *&value_out, +int +ACE_Naming_Context::resolve (const char *name_in, + char *&value_out, char *&type_out) { ACE_TRACE ("ACE_Naming_Context::resolve"); @@ -210,110 +210,110 @@ ACE_Naming_Context::resolve (const char *name_in, return value_out == 0 ? -1 : 0; } -int +int ACE_Naming_Context::unbind (const ACE_WString &name_in) { ACE_TRACE ("ACE_Naming_Context::unbind"); return this->name_space_->unbind (name_in); } -int +int ACE_Naming_Context::unbind (const char *name_in) { ACE_TRACE ("ACE_Naming_Context::unbind"); return this->unbind (ACE_WString (name_in)); } -int -ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out, +int +ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out, const ACE_WString &pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_names"); return this->name_space_->list_names (set_out, pattern_in); } -int -ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out, +int +ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out, const char *pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_names"); return this->list_names (set_out, ACE_WString (pattern_in)); } -int -ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out, +int +ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out, const ACE_WString &pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_values"); return this->name_space_->list_values (set_out, pattern_in); } -int -ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out, +int +ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out, const char *pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_values"); return this->list_values (set_out, ACE_WString (pattern_in)); } -int -ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out, +int +ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out, const ACE_WString &pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_types"); return this->name_space_->list_types (set_out, pattern_in); } -int -ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out, +int +ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out, const char *pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_types"); return this->list_types (set_out, ACE_WString (pattern_in)); } -int -ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out, +int +ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out, const ACE_WString &pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_name_entries"); return this->name_space_->list_name_entries (set_out, pattern_in); } -int -ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out, +int +ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out, const char *pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_name_entries"); return this->list_name_entries (set_out, ACE_WString (pattern_in)); } -int -ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out, +int +ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out, const ACE_WString &pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_value_entries"); return this->name_space_->list_value_entries (set_out, pattern_in); } -int -ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out, +int +ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out, const char *pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_value_entries"); return this->list_value_entries (set_out, ACE_WString (pattern_in)); } -int -ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out, +int +ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out, const ACE_WString &pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_type_entries"); return this->name_space_->list_type_entries (set_out, pattern_in); } -int -ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out, +int +ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out, const char *pattern_in) { ACE_TRACE ("ACE_Naming_Context::list_type_entries"); @@ -335,7 +335,7 @@ ACE_Naming_Context::dump () this->name_space_->dump(); } -int +int ACE_Naming_Context::init (int argc, char *argv[]) { ACE_DEBUG ((LM_DEBUG, "ACE_Naming_Context::init\n")); @@ -343,7 +343,7 @@ ACE_Naming_Context::init (int argc, char *argv[]) return this->open (this->name_options_->context ()); } -int +int ACE_Naming_Context::fini (void) { ACE_DEBUG ((LM_DEBUG, "ACE_Naming_Context::fini\n")); @@ -377,7 +377,7 @@ ACE_Name_Options::~ACE_Name_Options (void) ACE_OS::free ((void *) this->database_ ); } -void +void ACE_Name_Options::nameserver_port (int port) { ACE_TRACE ("ACE_Name_Options::nameserver_port"); @@ -391,7 +391,7 @@ ACE_Name_Options::nameserver_port (void) return this->nameserver_port_; } -void +void ACE_Name_Options::namespace_dir (LPCTSTR dir) { ACE_TRACE ("ACE_Name_Options::namespace_dir"); @@ -399,7 +399,7 @@ ACE_Name_Options::namespace_dir (LPCTSTR dir) this->namespace_dir_ = ACE_OS::strdup (dir); } -void +void ACE_Name_Options::process_name (LPCTSTR pname) { ACE_TRACE ("ACE_Name_Options::process_name"); @@ -408,7 +408,7 @@ ACE_Name_Options::process_name (LPCTSTR pname) this->process_name_ = ACE_OS::strdup (t); } -void +void ACE_Name_Options::nameserver_host (const char *host) { ACE_TRACE ("ACE_Name_Options::nameserver_host"); @@ -430,7 +430,7 @@ ACE_Name_Options::database (void) return this->database_; } -void +void ACE_Name_Options::database (LPCTSTR db) { ACE_TRACE ("ACE_Name_Options::database"); @@ -445,7 +445,7 @@ ACE_Name_Options::base_address (void) return this->base_address_; } -void +void ACE_Name_Options::base_address (char *base_address) { ACE_TRACE ("ACE_Name_Options::base_address"); @@ -459,7 +459,7 @@ ACE_Name_Options::context (void) return this->context_; } -void +void ACE_Name_Options::context (ACE_Naming_Context::Context_Scope_Type context) { ACE_TRACE ("ACE_Name_Options::context"); @@ -480,14 +480,14 @@ ACE_Name_Options::namespace_dir (void) return this->namespace_dir_; } -int +int ACE_Name_Options::debug (void) { ACE_TRACE ("ACE_Name_Options::debug"); return this->debugging_; } -int +int ACE_Name_Options::use_registry (void) { ACE_TRACE ("ACE_Name_Options::use_registry"); @@ -501,7 +501,7 @@ ACE_Name_Options::use_registry (int x) this->use_registry_ = x; } -int +int ACE_Name_Options::verbose (void) { ACE_TRACE ("ACE_Name_Options::verbose"); @@ -588,7 +588,7 @@ ACE_Name_Options::parse_args (int argc, char *argv[]) } } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Local_Name_Space <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex>; template class ACE_Local_Name_Space <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex>; template class ACE_Malloc<ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex>; @@ -597,4 +597,14 @@ template class ACE_Allocator_Adapter<ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_RW_Pro template class ACE_Allocator_Adapter<ACE_Malloc<ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> >; template class ACE_Name_Space_Map <ACE_Allocator_Adapter <ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > >; template class ACE_Name_Space_Map <ACE_Allocator_Adapter <ACE_Malloc <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > >; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Local_Name_Space <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> +#pragma instantiate ACE_Local_Name_Space <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> +#pragma instantiate ACE_Malloc<ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> +#pragma instantiate ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> +#pragma instantiate ACE_Allocator_Adapter<ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > +#pragma instantiate ACE_Allocator_Adapter<ACE_Malloc<ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > +#pragma instantiate ACE_Name_Space_Map <ACE_Allocator_Adapter <ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > > +#pragma instantiate ACE_Name_Space_Map <ACE_Allocator_Adapter <ACE_Malloc <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > > +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index 601cd96be50..b0b0cd21de3 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -77,8 +77,13 @@ ACE_Object_Manager::at_exit_i (void *object, return registered_objects_.enqueue_head (new_info); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Unbounded_Queue<ACE_Object_Manager::object_info_t>; template class ACE_Unbounded_Queue_Iterator<ACE_Object_Manager::object_info_t>; template class ACE_Node<ACE_Object_Manager::object_info_t>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Unbounded_Queue<ACE_Object_Manager::object_info_t> +#pragma instantiate ACE_Unbounded_Queue_Iterator<ACE_Object_Manager::object_info_t> +#pragma instantiate ACE_Node<ACE_Object_Manager::object_info_t> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Parse_Node.cpp b/ace/Parse_Node.cpp index 95de6ac8663..f7b5158d26b 100644 --- a/ace/Parse_Node.cpp +++ b/ace/Parse_Node.cpp @@ -34,12 +34,12 @@ ACE_Stream_Node::apply (void) { ACE_TRACE ("ACE_Stream_Node::apply"); - if (ACE_Service_Config::initialize (this->node_->record (), + if (ACE_Service_Config::initialize (this->node_->record (), this->node_->parameters ()) == -1) ace_yyerrno++; - ACE_DEBUG ((LM_DEBUG, "did stream on %s, error = %d\n", - this->node_->name (), + ACE_DEBUG ((LM_DEBUG, "did stream on %s, error = %d\n", + this->node_->name (), ace_yyerrno)); } @@ -65,18 +65,18 @@ ACE_Parse_Node::link (void) const return this->next_; } -void +void ACE_Parse_Node::link (ACE_Parse_Node *n) { ACE_TRACE ("ACE_Parse_Node::link"); this->next_ = n; } -ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops, +ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops, const ACE_Parse_Node *str_mods) : ACE_Parse_Node (str_ops->name ()), - node_ (str_ops), - mods_ (str_mods) + node_ (str_ops), + mods_ (str_mods) { ACE_TRACE ("ACE_Stream_Node::ACE_Stream_Node"); } @@ -97,7 +97,7 @@ ACE_Parse_Node::ACE_Parse_Node (void) ACE_Parse_Node::ACE_Parse_Node (const char *nm) - : name_ (nm), + : name_ (nm), next_ (0) { ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node"); @@ -154,7 +154,7 @@ ACE_Suspend_Node::apply (void) if (ACE_Service_Config::suspend (this->name ()) == -1) ace_yyerrno++; - ACE_DEBUG ((LM_DEBUG, "did suspend on %s, error = %d\n", + ACE_DEBUG ((LM_DEBUG, "did suspend on %s, error = %d\n", this->name (), ace_yyerrno)); } @@ -165,7 +165,7 @@ ACE_Resume_Node::apply (void) if (ACE_Service_Config::resume (this->name ()) == -1) ace_yyerrno++; - ACE_DEBUG ((LM_DEBUG, "did resume on %s, error = %d\n", + ACE_DEBUG ((LM_DEBUG, "did resume on %s, error = %d\n", this->name (), ace_yyerrno)); } @@ -190,7 +190,7 @@ ACE_Remove_Node::apply (void) if (ACE_Service_Config::remove (this->name ()) == -1) ace_yyerrno++; - ACE_DEBUG ((LM_DEBUG, "did remove on %s, error = %d\n", + ACE_DEBUG ((LM_DEBUG, "did remove on %s, error = %d\n", this->name (), ace_yyerrno)); } @@ -215,11 +215,11 @@ void ACE_Dynamic_Node::apply (void) { ACE_TRACE ("ACE_Dynamic_Node::apply"); - if (ACE_Service_Config::initialize (this->record (), + if (ACE_Service_Config::initialize (this->record (), this->parameters ()) == -1) ace_yyerrno++; - - ACE_DEBUG ((LM_DEBUG, "did dynamic on %s, error = %d\n", + + ACE_DEBUG ((LM_DEBUG, "did dynamic on %s, error = %d\n", this->name (), ace_yyerrno)); } @@ -245,9 +245,9 @@ ACE_Static_Node::dump (void) const ACE_TRACE ("ACE_Static_Node::dump"); } -ACE_Static_Node::ACE_Static_Node (const char *nm, +ACE_Static_Node::ACE_Static_Node (const char *nm, char *params) - : ACE_Parse_Node (nm), + : ACE_Parse_Node (nm), parameters_ (params) { ACE_TRACE ("ACE_Static_Node::ACE_Static_Node"); @@ -259,7 +259,7 @@ ACE_Static_Node::record (void) const ACE_TRACE ("ACE_Static_Node::record"); ACE_Service_Record *sr; - if (ACE_Service_Repository::instance()->find (this->name (), + if (ACE_Service_Repository::instance()->find (this->name (), (const ACE_Service_Record **) &sr) == -1) return 0; else @@ -277,11 +277,11 @@ void ACE_Static_Node::apply (void) { ACE_TRACE ("ACE_Static_Node::apply"); - if (ACE_Service_Config::initialize (this->name (), + if (ACE_Service_Config::initialize (this->name (), this->parameters ()) == -1) ace_yyerrno++; - - ACE_DEBUG ((LM_DEBUG, "did static on %s, error = %d\n", + + ACE_DEBUG ((LM_DEBUG, "did static on %s, error = %d\n", this->name (), ace_yyerrno)); } @@ -300,8 +300,8 @@ ACE_Location_Node::dump (void) const } ACE_Location_Node::ACE_Location_Node (void) - : handle_ (0), - symbol_ (0), + : handle_ (0), + symbol_ (0), pathname_ (0) { ACE_TRACE ("ACE_Location_Node::ACE_Location_Node"); @@ -319,14 +319,14 @@ ACE_Location_Node::pathname (void) const return this->pathname_; } -void +void ACE_Location_Node::pathname (const char *p) { ACE_TRACE ("ACE_Location_Node::pathname"); this->pathname_ = p; } -void +void ACE_Location_Node::handle (const ACE_SHLIB_HANDLE h) { ACE_TRACE ("ACE_Location_Node::handle"); @@ -340,7 +340,7 @@ ACE_Location_Node::handle (void) const return this->handle_; } -void +void ACE_Location_Node::set_symbol (const void *s) { ACE_TRACE ("ACE_Location_Node::set_symbol"); @@ -363,10 +363,10 @@ ACE_Location_Node::open_handle (void) // Transform the pathname into the appropriate dynamic link library // by searching the ACE_LD_SEARCH_PATH. - ACE::ldfind (this->pathname (), - dl_pathname, + ACE::ldfind (this->pathname (), + dl_pathname, (sizeof dl_pathname / sizeof (char))); - + this->handle (ACE_OS::dlopen (dl_pathname)); if (this->handle () == 0) @@ -394,7 +394,7 @@ ACE_Object_Node::dump (void) const ACE_TRACE ("ACE_Object_Node::dump"); } -ACE_Object_Node::ACE_Object_Node (const char *path, +ACE_Object_Node::ACE_Object_Node (const char *path, const char *obj_name) : object_name_ (obj_name) { @@ -409,7 +409,7 @@ ACE_Object_Node::symbol (void) ACE_TRACE ("ACE_Object_Node::symbol"); if (this->open_handle () != 0) { - this->symbol_ = (const void *) + this->symbol_ = (const void *) ACE_OS::dlsym ((ACE_SHLIB_HANDLE) this->handle (), (char *) this->object_name_); @@ -417,12 +417,12 @@ ACE_Object_Node::symbol (void) { ace_yyerrno++; - ACE_ERROR ((LM_ERROR, - "dlsym failed for object %s\n", + ACE_ERROR ((LM_ERROR, + "dlsym failed for object %s\n", this->object_name_)); char *errmsg = ACE_OS::dlerror (); - + if (errmsg != 0) ACE_ERROR_RETURN ((LM_ERROR, ": %s\n", errmsg), 0); else @@ -447,7 +447,7 @@ ACE_Function_Node::dump (void) const ACE_TRACE ("ACE_Function_Node::dump"); } -ACE_Function_Node::ACE_Function_Node (const char *path, +ACE_Function_Node::ACE_Function_Node (const char *path, const char *func_name) : function_name_ (func_name) { @@ -468,8 +468,8 @@ ACE_Function_Node::symbol (void) // Locate the factory function <function_name> in the shared // object. - func = (const void *(*)(void)) - ACE_OS::dlsym ((ACE_SHLIB_HANDLE) this->handle (), + func = (const void *(*)(void)) + ACE_OS::dlsym ((ACE_SHLIB_HANDLE) this->handle (), (ACE_DL_TYPE) this->function_name_); if (func == 0) @@ -480,11 +480,11 @@ ACE_Function_Node::symbol (void) { ace_yyerrno++; - ACE_ERROR ((LM_ERROR, "dlsym failed for function %s\n", + ACE_ERROR ((LM_ERROR, "dlsym failed for function %s\n", this->function_name_)); char *errmsg = ACE_OS::dlerror (); - + if (errmsg != 0) ACE_ERROR_RETURN ((LM_ERROR, ": %s\n", errmsg), 0); else @@ -516,10 +516,10 @@ ACE_Dummy_Node::dump (void) const ACE_TRACE ("ACE_Dummy_Node::dump"); } -ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node, +ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node, const ACE_Parse_Node *str_mods) : ACE_Parse_Node (static_node->name ()), - node_ (static_node), + node_ (static_node), mods_ (str_mods) { ACE_TRACE ("ACE_Dummy_Node::ACE_Dummy_Node"); @@ -529,7 +529,7 @@ void ACE_Dummy_Node::apply (void) { ACE_TRACE ("ACE_Dummy_Node::apply"); - ACE_DEBUG ((LM_DEBUG, "did operations on stream %s, error = %d\n", + ACE_DEBUG ((LM_DEBUG, "did operations on stream %s, error = %d\n", this->name (), ace_yyerrno)); } @@ -540,5 +540,7 @@ ACE_Dummy_Node::~ACE_Dummy_Node (void) delete (ACE_Parse_Node *) this->mods_; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index 6d864504a3f..5c8a0dc72c6 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -91,9 +91,9 @@ ACE_Reactor_Handler_Repository::open (size_t size) this->max_handlep1_ = 0; #if defined (ACE_WIN32) - // Try to allocate the memory. - ACE_NEW_RETURN (this->event_handlers_, - ACE_NT_EH_Record[size], + // Try to allocate the memory. + ACE_NEW_RETURN (this->event_handlers_, + ACE_NT_EH_Record[size], -1); // Initialize the ACE_Event_Handler * to { ACE_INVALID_HANDLE, 0 }. @@ -103,9 +103,9 @@ ACE_Reactor_Handler_Repository::open (size_t size) ACE_REACTOR_EVENT_HANDLER (this, h) = 0; } #else - // Try to allocate the memory. - ACE_NEW_RETURN (this->event_handlers_, - ACE_Event_Handler *[size], + // Try to allocate the memory. + ACE_NEW_RETURN (this->event_handlers_, + ACE_Event_Handler *[size], -1); // Initialize the ACE_Event_Handler * to NULL. @@ -119,7 +119,7 @@ ACE_Reactor_Handler_Repository::open (size_t size) ACE_Reactor_Handler_Repository::ACE_Reactor_Handler_Repository (ACE_Reactor &reactor) : reactor_ (reactor), - max_size_ (0), + max_size_ (0), max_handlep1_ (0), event_handlers_ (0) { @@ -130,8 +130,8 @@ int ACE_Reactor_Handler_Repository::unbind_all (void) { // Unbind all of the <handle, ACE_Event_Handler>s. - for (int handle = 0; - handle < this->max_handlep1_; + for (int handle = 0; + handle < this->max_handlep1_; handle++) this->unbind (ACE_REACTOR_HANDLE (handle), ACE_Event_Handler::ALL_EVENTS_MASK); @@ -187,7 +187,7 @@ ACE_Reactor_Handler_Repository::find (ACE_HANDLE handle, // g++ can't figure out that i won't be used below if the handle // is out of range, so keep it happy by defining i here . . . i = 0; - + if (eh != 0 && index_p != 0) *index_p = i; else @@ -198,8 +198,8 @@ ACE_Reactor_Handler_Repository::find (ACE_HANDLE handle, // Bind the <ACE_Event_Handler *> to the <ACE_HANDLE>. -int -ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, +int +ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { @@ -236,7 +236,7 @@ ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, } else if (this->max_handlep1_ < this->max_size_) { - // Insert at the end of the active portion. + // Insert at the end of the active portion. ACE_REACTOR_HANDLE (this->max_handlep1_) = handle; ACE_REACTOR_EVENT_HANDLER (this, this->max_handlep1_) = event_handler; this->max_handlep1_++; @@ -255,8 +255,8 @@ ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, #endif /* ACE_WIN32 */ // Add the <mask> for this <handle> in the Reactor's wait_set. - this->reactor_.bit_ops (handle, - mask, + this->reactor_.bit_ops (handle, + mask, this->reactor_.wait_set_, ACE_Reactor::ADD_MASK); @@ -272,7 +272,7 @@ ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, // Remove the binding of <ACE_HANDLE>. -int +int ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, ACE_Reactor_Mask mask) { @@ -285,8 +285,8 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, return -1; // Clear out the <mask> bits in the Reactor's wait_set. - this->reactor_.bit_ops (handle, - mask, + this->reactor_.bit_ops (handle, + mask, this->reactor_.wait_set_, ACE_Reactor::CLR_MASK); @@ -303,7 +303,7 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, // If there are no longer any outstanding events on this <handle> // then we can totally shut down the Event_Handler. if (this->reactor_.wait_set_.rd_mask_.is_set (handle) == 0 - && this->reactor_.wait_set_.wr_mask_.is_set (handle) == 0 + && this->reactor_.wait_set_.wr_mask_.is_set (handle) == 0 && this->reactor_.wait_set_.ex_mask_.is_set (handle) == 0) #if defined (ACE_WIN32) { @@ -311,7 +311,7 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, ACE_REACTOR_EVENT_HANDLER (this, index) = 0; if (this->max_handlep1_ == (int) index + 1) - { + { // We've deleted the last entry (i.e., i + 1 == the current // size of the array), so we need to figure out the last // valid place in the array that we should consider in @@ -321,14 +321,14 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, i >= 0 && ACE_REACTOR_HANDLE (i) == ACE_INVALID_HANDLE; i--) continue; - + this->max_handlep1_ = i + 1; } } #else - { + { ACE_REACTOR_EVENT_HANDLER (this, handle) = 0; - + if (this->max_handlep1_ == handle + 1) { // We've deleted the last entry, so we need to figure out @@ -352,7 +352,7 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, return 0; } -ACE_Reactor_Handler_Repository_Iterator::ACE_Reactor_Handler_Repository_Iterator +ACE_Reactor_Handler_Repository_Iterator::ACE_Reactor_Handler_Repository_Iterator (const ACE_Reactor_Handler_Repository *s) : rep_ (s), current_ (-1) @@ -363,7 +363,7 @@ ACE_Reactor_Handler_Repository_Iterator::ACE_Reactor_Handler_Repository_Iterator // Pass back the <next_item> that hasn't been seen in the Set. // Returns 0 when all items have been seen, else 1. -int +int ACE_Reactor_Handler_Repository_Iterator::next (ACE_Event_Handler *&next_item) { int result = 1; @@ -371,12 +371,12 @@ ACE_Reactor_Handler_Repository_Iterator::next (ACE_Event_Handler *&next_item) if (this->current_ >= this->rep_->max_handlep1_) result = 0; else - next_item = ACE_REACTOR_EVENT_HANDLER (this->rep_, + next_item = ACE_REACTOR_EVENT_HANDLER (this->rep_, this->current_); return result; } -int +int ACE_Reactor_Handler_Repository_Iterator::done (void) const { return this->current_ >= this->rep_->max_handlep1_; @@ -384,7 +384,7 @@ ACE_Reactor_Handler_Repository_Iterator::done (void) const // Move forward by one element in the set. -int +int ACE_Reactor_Handler_Repository_Iterator::advance (void) { if (this->current_ < this->rep_->max_handlep1_) @@ -396,12 +396,12 @@ ACE_Reactor_Handler_Repository_Iterator::advance (void) else this->current_++; - return this->current_ < this->rep_->max_handlep1_; + return this->current_ < this->rep_->max_handlep1_; } // Dump the state of an object. -void +void ACE_Reactor_Handler_Repository_Iterator::dump (void) const { ACE_TRACE ("ACE_Reactor_Handler_Repository_Iterator::dump"); @@ -409,7 +409,7 @@ ACE_Reactor_Handler_Repository_Iterator::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "rep_ = %u", this->rep_)); ACE_DEBUG ((LM_DEBUG, "current_ = %d", this->current_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } void @@ -418,9 +418,9 @@ ACE_Reactor_Handler_Repository::dump (void) const ACE_TRACE ("ACE_Reactor_Handler_Repository::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) max_handlep1_ = %d, max_size_ = %d\n", - this->max_handlep1_, this->max_size_)); + this->max_handlep1_, this->max_size_)); ACE_DEBUG ((LM_DEBUG, "[")); ACE_Event_Handler *eh = 0; @@ -428,16 +428,16 @@ ACE_Reactor_Handler_Repository::dump (void) const for (ACE_Reactor_Handler_Repository_Iterator iter (this); iter.next (eh) != 0; iter.advance ()) - ACE_DEBUG ((LM_DEBUG, " (eh = %x, eh->handle_ = %d)", + ACE_DEBUG ((LM_DEBUG, " (eh = %x, eh->handle_ = %d)", eh, eh->get_handle ())); ACE_DEBUG ((LM_DEBUG, " ]")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_ALLOC_HOOK_DEFINE(ACE_Reactor_Handler_Repository_Iterator) -int +int ACE_Reactor::any_ready (ACE_Reactor_Handle_Set &wait_set) { ACE_TRACE ("ACE_Reactor::fill_in_ready"); @@ -447,7 +447,7 @@ ACE_Reactor::any_ready (ACE_Reactor_Handle_Set &wait_set) ACE_Sig_Guard sb; #endif /* ACE_WIN32 */ - int number_ready = this->ready_set_.rd_mask_.num_set () + int number_ready = this->ready_set_.rd_mask_.num_set () + this->ready_set_.wr_mask_.num_set () + this->ready_set_.ex_mask_.num_set (); @@ -465,7 +465,7 @@ ACE_Reactor::any_ready (ACE_Reactor_Handle_Set &wait_set) return number_ready; } -int +int ACE_Reactor::handler_i (int signum, ACE_Event_Handler **eh) { ACE_TRACE ("ACE_Reactor::handler_i"); @@ -496,7 +496,7 @@ ACE_Reactor::owner (ACE_thread_t tid, ACE_thread_t *o_id) *o_id = this->owner_; this->owner_ = tid; - + return 0; } @@ -509,7 +509,7 @@ ACE_Reactor::owner (ACE_thread_t *t_id) return 0; } -void +void ACE_Reactor::requeue_position (int rp) { ACE_TRACE ("ACE_Reactor::requeue_position"); @@ -522,7 +522,7 @@ ACE_Reactor::requeue_position (int rp) #endif /* ACE_WIN32 */ } -int +int ACE_Reactor::requeue_position (void) { ACE_TRACE ("ACE_Reactor::requeue_position"); @@ -530,7 +530,7 @@ ACE_Reactor::requeue_position (void) return this->requeue_position_; } -void +void ACE_Reactor::max_notify_iterations (int iterations) { ACE_TRACE ("ACE_Reactor::max_notify_iterations"); @@ -543,7 +543,7 @@ ACE_Reactor::max_notify_iterations (int iterations) this->max_notify_iterations_ = iterations; } -int +int ACE_Reactor::max_notify_iterations (void) { ACE_TRACE ("ACE_Reactor::max_notify_iterations"); @@ -553,7 +553,7 @@ ACE_Reactor::max_notify_iterations (void) #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) // Enqueue ourselves into the list of waiting threads. -void +void ACE_Reactor::renew (void) { ACE_TRACE ("ACE_Reactor::renew"); @@ -567,7 +567,7 @@ ACE_Reactor_Token::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "\n")); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } ACE_Reactor_Token::ACE_Reactor_Token (ACE_Reactor &r) @@ -597,7 +597,7 @@ ACE_Reactor_Notify::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "reactor_ = %x", this->reactor_)); this->notification_pipe_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } int @@ -612,11 +612,11 @@ ACE_Reactor_Notify::open (ACE_Reactor *r) // There seems to be a Win32 bug with this... Set this into // non-blocking mode. - if (ACE::set_flags (this->notification_pipe_.read_handle (), + if (ACE::set_flags (this->notification_pipe_.read_handle (), ACE_NONBLOCK) == -1) return -1; - else - return this->reactor_->register_handler + else + return this->reactor_->register_handler (this->notification_pipe_.read_handle (), this, ACE_Event_Handler::READ_MASK); @@ -630,8 +630,8 @@ ACE_Reactor_Notify::close (void) } ssize_t -ACE_Reactor_Notify::notify (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask, +ACE_Reactor_Notify::notify (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask, ACE_Time_Value *timeout) { ACE_TRACE ("ACE_Reactor_Notify::notify"); @@ -639,7 +639,7 @@ ACE_Reactor_Notify::notify (ACE_Event_Handler *eh, ACE_Notification_Buffer buffer (eh, mask); ssize_t n = ACE::send (this->notification_pipe_.write_handle (), - (char *) &buffer, + (char *) &buffer, sizeof buffer, timeout); return n == -1 ? -1 : 0; @@ -654,7 +654,7 @@ ACE_Reactor_Notify::dispatch_notifications (int &number_of_active_handles, { ACE_TRACE ("ACE_Reactor_Notify::handle_notification"); - ACE_HANDLE read_handle = + ACE_HANDLE read_handle = this->notification_pipe_.read_handle (); if (rd_mask.is_set (read_handle)) @@ -685,7 +685,7 @@ ACE_Reactor_Notify::handle_input (ACE_HANDLE handle) while ((n = ACE::recv (handle, (char *) &buffer, sizeof buffer)) > 0) { // Check to see if we've got a short read. - if (n != sizeof buffer) + if (n != sizeof buffer) { ssize_t remainder = sizeof buffer - n; @@ -722,7 +722,7 @@ ACE_Reactor_Notify::handle_input (ACE_HANDLE handle) ACE_ERROR ((LM_ERROR, "invalid mask = %d\n", buffer.mask_)); } if (result == -1) - buffer.eh_->handle_close (ACE_INVALID_HANDLE, + buffer.eh_->handle_close (ACE_INVALID_HANDLE, ACE_Event_Handler::EXCEPT_MASK); } @@ -750,7 +750,7 @@ ACE_Reactor_Notify::handle_input (ACE_HANDLE handle) #endif /* ACE_MT_SAFE */ int -ACE_Reactor::notify (ACE_Event_Handler *eh, +ACE_Reactor::notify (ACE_Event_Handler *eh, ACE_Reactor_Mask mask, ACE_Time_Value *timeout) { @@ -821,7 +821,7 @@ ACE_Reactor::resume_handlers (void) } int -ACE_Reactor::register_handler (ACE_Event_Handler *handler, +ACE_Reactor::register_handler (ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::register_handler"); @@ -830,8 +830,8 @@ ACE_Reactor::register_handler (ACE_Event_Handler *handler, } int -ACE_Reactor::register_handler (ACE_HANDLE handle, - ACE_Event_Handler *handler, +ACE_Reactor::register_handler (ACE_HANDLE handle, + ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::register_handler"); @@ -840,8 +840,8 @@ ACE_Reactor::register_handler (ACE_HANDLE handle, } int -ACE_Reactor::register_handler (const ACE_Handle_Set &handles, - ACE_Event_Handler *handler, +ACE_Reactor::register_handler (const ACE_Handle_Set &handles, + ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::register_handler"); @@ -850,8 +850,8 @@ ACE_Reactor::register_handler (const ACE_Handle_Set &handles, } int -ACE_Reactor::handler (ACE_HANDLE handle, - ACE_Reactor_Mask mask, +ACE_Reactor::handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, ACE_Event_Handler **handler) { ACE_TRACE ("ACE_Reactor::handler"); @@ -860,7 +860,7 @@ ACE_Reactor::handler (ACE_HANDLE handle, } int -ACE_Reactor::remove_handler (const ACE_Handle_Set &handles, +ACE_Reactor::remove_handler (const ACE_Handle_Set &handles, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::remove_handler"); @@ -869,7 +869,7 @@ ACE_Reactor::remove_handler (const ACE_Handle_Set &handles, } int -ACE_Reactor::remove_handler (ACE_Event_Handler *handler, +ACE_Reactor::remove_handler (ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::remove_handler"); @@ -878,7 +878,7 @@ ACE_Reactor::remove_handler (ACE_Event_Handler *handler, } int -ACE_Reactor::remove_handler (ACE_HANDLE handle, +ACE_Reactor::remove_handler (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::remove_handler"); @@ -889,13 +889,13 @@ ACE_Reactor::remove_handler (ACE_HANDLE handle, // Performs operations on the "ready" bits. int -ACE_Reactor::ready_ops (ACE_HANDLE handle, - ACE_Reactor_Mask mask, +ACE_Reactor::ready_ops (ACE_HANDLE handle, + ACE_Reactor_Mask mask, int ops) { ACE_TRACE ("ACE_Reactor::ready_ops"); ACE_MT (ACE_GUARD_RETURN (ACE_REACTOR_MUTEX, ace_mon, this->token_, -1)); - return this->bit_ops (handle, + return this->bit_ops (handle, mask, this->ready_set_, ops); @@ -905,16 +905,16 @@ ACE_Reactor * ACE_Reactor::instance (size_t size /* = ACE_Reactor::DEFAULT_SIZE */) { ACE_TRACE ("ACE_Reactor::instance"); - + if (ACE_Reactor::reactor_ == 0) { // Perform Double-Checked Locking Optimization. ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_Static_Object_Lock::instance (), 0)); - + if (ACE_Reactor::reactor_ == 0) { - ACE_NEW_RETURN (ACE_Reactor::reactor_, ACE_Reactor (size), NULL); + ACE_NEW_RETURN (ACE_Reactor::reactor_, ACE_Reactor (size), NULL); ACE_Reactor::delete_reactor_ = 1; } } @@ -1007,7 +1007,7 @@ ACE_Reactor::end_event_loop (void) // Send a notification, but don't block if there's no one to receive // it. - return ACE_Reactor::instance ()->notify + return ACE_Reactor::instance ()->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero); } @@ -1022,8 +1022,8 @@ ACE_Reactor::event_loop_done (void) // Initialize the ACE_Reactor int -ACE_Reactor::open (size_t size, - int restart, +ACE_Reactor::open (size_t size, + int restart, ACE_Sig_Handler *sh, ACE_Timer_Queue *tq) { @@ -1045,7 +1045,7 @@ ACE_Reactor::open (size_t size, if (this->signal_handler_ == 0) { this->signal_handler_ = new ACE_Sig_Handler; - + if (this->signal_handler_ == 0) result = -1; else @@ -1101,8 +1101,8 @@ ACE_Reactor::ACE_Reactor (ACE_Sig_Handler *sh, // Initialize ACE_Reactor. -ACE_Reactor::ACE_Reactor (size_t size, - int rs, +ACE_Reactor::ACE_Reactor (size_t size, + int rs, ACE_Sig_Handler *sh, ACE_Timer_Queue *tq) : handler_rep_ (*this), @@ -1148,7 +1148,7 @@ ACE_Reactor::close (void) #endif /* ACE_MT_SAFE */ this->initialized_ = 0; } - + ACE_Reactor::~ACE_Reactor (void) { ACE_TRACE ("ACE_Reactor::~ACE_Reactor"); @@ -1168,12 +1168,12 @@ ACE_Reactor::remove_handler_i (const ACE_Handle_Set &handles, if (this->remove_handler_i (h, mask) == -1) return -1; - return 0; + return 0; } int -ACE_Reactor::register_handler_i (const ACE_Handle_Set &handles, - ACE_Event_Handler *handler, +ACE_Reactor::register_handler_i (const ACE_Handle_Set &handles, + ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::register_handler_i"); @@ -1184,11 +1184,11 @@ ACE_Reactor::register_handler_i (const ACE_Handle_Set &handles, if (this->register_handler_i (h, handler, mask) == -1) return -1; - return 0; + return 0; } int -ACE_Reactor::register_handler (const ACE_Sig_Set &sigset, +ACE_Reactor::register_handler (const ACE_Sig_Set &sigset, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp) { @@ -1199,9 +1199,9 @@ ACE_Reactor::register_handler (const ACE_Sig_Set &sigset, #if (NSIG > 0) for (int s = 1; s < NSIG; s++) - if (sigset.is_member (s) - && this->signal_handler_->register_handler (s, new_sh, - new_disp) == -1) + if (sigset.is_member (s) + && this->signal_handler_->register_handler (s, new_sh, + new_disp) == -1) result = -1; #endif /* NSIG */ return result; @@ -1215,35 +1215,35 @@ ACE_Reactor::remove_handler (const ACE_Sig_Set &sigset) #if (NSIG == 0) for (int s = 1; s < NSIG; s++) - if (sigset.is_member (s) + if (sigset.is_member (s) && this->signal_handler_->remove_handler (s) == -1) result = -1; #else ACE_UNUSED_ARG (sigset); #endif /* NSIG */ - return result; + return result; } -// Note the queue handles its own locking. +// Note the queue handles its own locking. long -ACE_Reactor::schedule_timer (ACE_Event_Handler *handler, +ACE_Reactor::schedule_timer (ACE_Event_Handler *handler, const void *arg, - const ACE_Time_Value &delta_time, + const ACE_Time_Value &delta_time, const ACE_Time_Value &interval) { ACE_TRACE ("ACE_Reactor::schedule_timer"); ACE_MT (ACE_GUARD_RETURN (ACE_REACTOR_MUTEX, ace_mon, this->token_, -1)); - return this->timer_queue_->schedule + return this->timer_queue_->schedule (handler, arg, timer_queue_->gettimeofday () + delta_time, interval); } // Main event loop driver that blocks for <max_wait_time> before // returning (will return earlier if I/O or signal events occur). -int +int ACE_Reactor::handle_events (ACE_Time_Value &max_wait_time) { ACE_TRACE ("ACE_Reactor::handle_events"); @@ -1264,8 +1264,8 @@ ACE_Reactor::handle_error (void) } void -ACE_Reactor::notify_handle (ACE_HANDLE handle, - ACE_Reactor_Mask mask, +ACE_Reactor::notify_handle (ACE_HANDLE handle, + ACE_Reactor_Mask mask, ACE_Handle_Set &ready_mask, ACE_Event_Handler *event_handler, ACE_EH_PTMF ptmf) @@ -1288,10 +1288,10 @@ ACE_Reactor::notify_handle (ACE_HANDLE handle, // GET = 1, Retrieve current value // SET = 2, Set value of bits to new mask (changes the entire mask) // ADD = 3, Bitwise "or" the value into the mask (only changes -// enabled bits) +// enabled bits) // CLR = 4 Bitwise "and" the negation of the value out of the mask -// (only changes enabled bits) -// +// (only changes enabled bits) +// // Returns the original mask. Must be called with locks held. int @@ -1305,7 +1305,7 @@ ACE_Reactor::bit_ops (ACE_HANDLE handle, return -1; #if !defined (ACE_WIN32) - ACE_Sig_Guard sb; // Block out all signals until method returns. + ACE_Sig_Guard sb; // Block out all signals until method returns. #endif /* ACE_WIN32 */ ACE_FDS_PTMF ptmf = &ACE_Handle_Set::set_bit; @@ -1361,32 +1361,32 @@ ACE_Reactor::bit_ops (ACE_HANDLE handle, else if (ops == ACE_Reactor::SET_MASK) handle_set.ex_mask_.clr_bit (handle); break; - default: + default: return -1; } return omask; } // Perform GET, CLR, SET, and ADD operations on the select() -// Handle_Sets. +// Handle_Sets. // // GET = 1, Retrieve current value -// SET = 2, Set value of bits to new mask (changes the entire mask) +// SET = 2, Set value of bits to new mask (changes the entire mask) // ADD = 3, Bitwise "or" the value into the mask (only changes -// enabled bits) +// enabled bits) // CLR = 4 Bitwise "and" the negation of the value out of the mask -// (only changes enabled bits) +// (only changes enabled bits) // // Returns the original mask. int -ACE_Reactor::mask_ops (ACE_HANDLE handle, - ACE_Reactor_Mask mask, +ACE_Reactor::mask_ops (ACE_HANDLE handle, + ACE_Reactor_Mask mask, int ops) { ACE_TRACE ("ACE_Reactor::mask_ops"); ACE_MT (ACE_GUARD_RETURN (ACE_REACTOR_MUTEX, ace_mon, this->token_, -1)); - return this->bit_ops (handle, mask, + return this->bit_ops (handle, mask, this->wait_set_, ops); } @@ -1394,9 +1394,9 @@ ACE_Reactor::mask_ops (ACE_HANDLE handle, // Must be called with locks held. int -ACE_Reactor::handler_i (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - ACE_Event_Handler **handler) +ACE_Reactor::handler_i (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **handler) { ACE_TRACE ("ACE_Reactor::handler_i"); ACE_Event_Handler *h = this->handler_rep_.find (handle); @@ -1413,7 +1413,7 @@ ACE_Reactor::handler_i (ACE_HANDLE handle, && this->wait_set_.wr_mask_.is_set (handle) == 0) return -1; if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK) - && this->wait_set_.ex_mask_.is_set (handle) == 0) + && this->wait_set_.ex_mask_.is_set (handle) == 0) return -1; } @@ -1430,7 +1430,7 @@ ACE_Reactor::resume_i (ACE_HANDLE handle) ACE_TRACE ("ACE_Reactor::resume"); if (this->handler_rep_.find (handle) == 0) return -1; - + this->wait_set_.rd_mask_.set_bit (handle); this->wait_set_.wr_mask_.set_bit (handle); this->wait_set_.ex_mask_.set_bit (handle); @@ -1455,7 +1455,7 @@ ACE_Reactor::suspend_i (ACE_HANDLE handle) // Must be called with locks held int -ACE_Reactor::register_handler_i (ACE_HANDLE handle, +ACE_Reactor::register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { @@ -1467,7 +1467,7 @@ ACE_Reactor::register_handler_i (ACE_HANDLE handle, } int -ACE_Reactor::remove_handler_i (ACE_HANDLE handle, +ACE_Reactor::remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_Reactor::remove_handler_i"); @@ -1478,7 +1478,7 @@ ACE_Reactor::remove_handler_i (ACE_HANDLE handle, // Must be called with lock held. -int +int ACE_Reactor::wait_for_multiple_events (ACE_Reactor_Handle_Set &dispatch_set, ACE_Time_Value *max_wait_time) { @@ -1500,19 +1500,19 @@ ACE_Reactor::wait_for_multiple_events (ACE_Reactor_Handle_Set &dispatch_set, this_timeout) == 0) { this_timeout = 0 ; } - + width = (u_long) this->handler_rep_.max_handlep1 (); dispatch_set.rd_mask_ = this->wait_set_.rd_mask_; dispatch_set.wr_mask_ = this->wait_set_.wr_mask_; dispatch_set.ex_mask_ = this->wait_set_.ex_mask_; - number_of_active_handles = ACE_OS::select (int (width), - dispatch_set.rd_mask_, - dispatch_set.wr_mask_, - dispatch_set.ex_mask_, + number_of_active_handles = ACE_OS::select (int (width), + dispatch_set.rd_mask_, + dispatch_set.wr_mask_, + dispatch_set.ex_mask_, this_timeout); - } + } while (number_of_active_handles == -1 && this->handle_error () > 0); if (number_of_active_handles > 0) @@ -1527,7 +1527,7 @@ ACE_Reactor::wait_for_multiple_events (ACE_Reactor_Handle_Set &dispatch_set, } // Return the number of events to dispatch. - return number_of_active_handles; + return number_of_active_handles; } int @@ -1547,9 +1547,9 @@ ACE_Reactor::dispatch_notification_handlers (int &number_of_active_handles, // other threads are trying to update the ACE_Reactor's internal // tables. We'll handle all these threads and then break out to // continue the event loop. - - int number_dispatched = - this->notify_handler_.dispatch_notifications (number_of_active_handles, + + int number_dispatched = + this->notify_handler_.dispatch_notifications (number_of_active_handles, dispatch_set.rd_mask_); return this->state_changed_ ? -1 : number_dispatched; #else @@ -1582,9 +1582,9 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, number_dispatched++; this->notify_handle (handle, ACE_Event_Handler::WRITE_MASK, - this->ready_set_.wr_mask_, + this->ready_set_.wr_mask_, this->handler_rep_.find (handle), - &ACE_Event_Handler::handle_output); + &ACE_Event_Handler::handle_output); } } @@ -1605,15 +1605,15 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, ACE_Handle_Set_Iterator handle_iter_ex (dispatch_set.ex_mask_); - while ((handle = handle_iter_ex ()) != ACE_INVALID_HANDLE + while ((handle = handle_iter_ex ()) != ACE_INVALID_HANDLE && number_dispatched < number_of_active_handles && this->state_changed_ == 0) { this->notify_handle (handle, ACE_Event_Handler::EXCEPT_MASK, - this->ready_set_.ex_mask_, + this->ready_set_.ex_mask_, this->handler_rep_.find (handle), - &ACE_Event_Handler::handle_exception); + &ACE_Event_Handler::handle_exception); number_dispatched++; } } @@ -1635,15 +1635,15 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, ACE_Handle_Set_Iterator handle_iter_rd (dispatch_set.rd_mask_); - while ((handle = handle_iter_rd ()) != ACE_INVALID_HANDLE + while ((handle = handle_iter_rd ()) != ACE_INVALID_HANDLE && number_dispatched < number_of_active_handles && this->state_changed_ == 0) { this->notify_handle (handle, ACE_Event_Handler::READ_MASK, - this->ready_set_.rd_mask_, + this->ready_set_.rd_mask_, this->handler_rep_.find (handle), - &ACE_Event_Handler::handle_input); + &ACE_Event_Handler::handle_input); number_dispatched++; } } @@ -1660,7 +1660,7 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, } int -ACE_Reactor::dispatch (int number_of_active_handles, +ACE_Reactor::dispatch (int number_of_active_handles, ACE_Reactor_Handle_Set &dispatch_set) { ACE_TRACE ("ACE_Reactor::dispatch"); @@ -1694,14 +1694,14 @@ ACE_Reactor::dispatch (int number_of_active_handles, if (this->dispatch_timer_handlers () == -1) // State has changed or timer queue has failed, exit inner // loop. - break; + break; else if (number_of_active_handles <= 0) // Bail out since we got here since select() was interrupted. { if (ACE_Sig_Handler::sig_pending () != 0) { ACE_Sig_Handler::sig_pending (0); - + // If any HANDLES in the <ready_set_> are activated as a // result of signals they should be dispatched since // they may be time critical... @@ -1710,13 +1710,13 @@ ACE_Reactor::dispatch (int number_of_active_handles, else return number_of_active_handles; } - else if (this->dispatch_notification_handlers + else if (this->dispatch_notification_handlers (number_of_active_handles, dispatch_set) == -1) break; // State has changed, exit inner loop. - else if (this->dispatch_io_handlers + else if (this->dispatch_io_handlers (number_of_active_handles, dispatch_set) == -1) // State has changed, so exit the inner loop. - break; + break; } while (number_of_active_handles > 0); @@ -1735,7 +1735,7 @@ ACE_Reactor::release_token (void) #endif /* ACE_WIN32 */ } -int +int ACE_Reactor::handle_events (ACE_Time_Value *max_wait_time) { ACE_TRACE ("ACE_Reactor::handle_events"); @@ -1758,7 +1758,7 @@ ACE_Reactor::handle_events (ACE_Time_Value *max_wait_time) return this->handle_events_i (max_wait_time); } -int +int ACE_Reactor::handle_events_i (ACE_Time_Value *max_wait_time) { int result; @@ -1766,9 +1766,9 @@ ACE_Reactor::handle_events_i (ACE_Time_Value *max_wait_time) ACE_SEH_TRY { ACE_Reactor_Handle_Set dispatch_set; - int number_of_active_handles = - this->wait_for_multiple_events (dispatch_set, - max_wait_time); + int number_of_active_handles = + this->wait_for_multiple_events (dispatch_set, + max_wait_time); result = this->dispatch (number_of_active_handles, dispatch_set); } @@ -1805,12 +1805,12 @@ ACE_Reactor::check_handles (void) rd_mask.set_bit (handle); - if (ACE_OS::select (int (handle) + 1, - rd_mask, 0, 0, + if (ACE_OS::select (int (handle) + 1, + rd_mask, 0, 0, &time_poll) < 0) { result = 1; - this->remove_handler_i (handle, + this->remove_handler_i (handle, ACE_Event_Handler::ALL_EVENTS_MASK); } rd_mask.clr_bit (handle); @@ -1829,8 +1829,8 @@ ACE_Reactor::dump (void) const this->timer_queue_->dump (); this->handler_rep_.dump (); this->signal_handler_->dump (); - ACE_DEBUG ((LM_DEBUG, - "delete_signal_handler_ = %d\n", + ACE_DEBUG ((LM_DEBUG, + "delete_signal_handler_ = %d\n", this->delete_signal_handler_)); ACE_HANDLE h; @@ -1875,10 +1875,16 @@ ACE_Reactor::dump (void) const this->token_.dump (); #endif /* ACE_MT_SAFE */ - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) ACE_MT (template class ACE_Guard<ACE_REACTOR_MUTEX>); template class ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#pragma instantiate ACE_Guard<ACE_REACTOR_MUTEX> +#endif /* ACE_MT_SAFE */ +#pragma instantiate ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Remote_Tokens.cpp b/ace/Remote_Tokens.cpp index 1165136669b..fbc37ae5165 100644 --- a/ace/Remote_Tokens.cpp +++ b/ace/Remote_Tokens.cpp @@ -16,7 +16,7 @@ typedef ACE_Null_Mutex ACE_TSS_CONNECTION_MUTEX; #endif /* ACE_MT_SAFE */ // Make a typedef to simplify access to the Singleton below. -typedef ACE_Singleton<ACE_TSS_Connection, ACE_TSS_CONNECTION_MUTEX> +typedef ACE_Singleton<ACE_TSS_Connection, ACE_TSS_CONNECTION_MUTEX> ACE_Token_Connections; // Initialize the statics from ACE_TSS_Connection; @@ -24,7 +24,7 @@ ACE_INET_Addr ACE_TSS_Connection::server_address_; // ************************************************************ -void +void ACE_TSS_Connection::set_server_address (const ACE_INET_Addr &server_address) { ACE_TRACE ("ACE_TSS_Connection::set_server_address"); @@ -85,7 +85,7 @@ ACE_TSS_Connection::dump (void) const server_address_.dump (); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_TSS<ACE_SOCK_Stream>::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } // ************************************************************ @@ -119,7 +119,7 @@ ACE_Remote_Token_Proxy::set_server_address (const ACE_INET_Addr &server_address) ACE_Token_Connections::instance ()->set_server_address (server_address); } -int +int ACE_Remote_Token_Proxy::initiate_connection (void) { ACE_TRACE ("ACE_Remote_Token_Proxy::initiate_connection"); @@ -144,7 +144,7 @@ ACE_Remote_Token_Proxy::request_reply (ACE_Token_Request &request, ssize_t length; if ((length = request.encode (buffer)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "encode failed"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "encode failed"), -1); ACE_SOCK_Stream *peer = ACE_Token_Connections::instance ()->get_connection (); @@ -158,7 +158,7 @@ ACE_Remote_Token_Proxy::request_reply (ACE_Token_Request &request, else { ACE_Token_Reply reply; - + // Receive reply via blocking read. if (peer->recv (&reply, sizeof reply) == -1) @@ -175,7 +175,7 @@ ACE_Remote_Token_Proxy::request_reply (ACE_Token_Request &request, } } -int +int ACE_Remote_Token_Proxy::acquire (int notify, void (*sleep_hook)(void *), ACE_Synch_Options &options) @@ -183,8 +183,8 @@ ACE_Remote_Token_Proxy::acquire (int notify, ACE_TRACE ("ACE_Remote_Token_Proxy::acquire"); // First grab the local shadow mutex. - if (ACE_Token_Proxy::acquire (notify, - sleep_hook, + if (ACE_Token_Proxy::acquire (notify, + sleep_hook, ACE_Synch_Options::asynch) == -1) { // Acquire failed, deal with it... @@ -211,9 +211,9 @@ ACE_Remote_Token_Proxy::acquire (int notify, } default : - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p shadow acquire failed\n", - "ACE_Remote_Token_Proxy"), + "ACE_Remote_Token_Proxy"), -1); } } @@ -222,7 +222,7 @@ ACE_Remote_Token_Proxy::acquire (int notify, this->type (), ACE_Token_Request::ACQUIRE, this->name (), - this->client_id (), + this->client_id (), options); request.notify (notify); @@ -249,7 +249,7 @@ ACE_Remote_Token_Proxy::acquire (int notify, return result; } -int +int ACE_Remote_Token_Proxy::tryacquire (void (*sleep_hook)(void *)) { ACE_TRACE ("ACE_Remote_Token_Proxy::tryacquire"); @@ -270,12 +270,12 @@ ACE_Remote_Token_Proxy::tryacquire (void (*sleep_hook)(void *)) ACE_Token_Request request (token_->type (), this->type (), - ACE_Token_Request::RELEASE, + ACE_Token_Request::RELEASE, this->name (), this->client_id (), ACE_Synch_Options::synch); - return this->request_reply (request, + return this->request_reply (request, ACE_Synch_Options::synch); } @@ -285,23 +285,23 @@ ACE_Remote_Token_Proxy::renew (int requeue_position, { ACE_TRACE ("ACE_Remote_Token_Proxy::renew"); - if (ACE_Token_Proxy::renew (requeue_position, + if (ACE_Token_Proxy::renew (requeue_position, ACE_Synch_Options::asynch) == -1) { // Check for error. if (errno != EWOULDBLOCK) return -1; else if (debug_) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) shadow: renew would block. owner %s.\n", this->token_->owner_id ())); } ACE_Token_Request request (token_->type (), this->type (), - ACE_Token_Request::RENEW, + ACE_Token_Request::RENEW, this->name (), - this->client_id (), + this->client_id (), options); request.requeue_position (requeue_position); @@ -333,9 +333,9 @@ ACE_Remote_Token_Proxy::release (ACE_Synch_Options &options) ACE_Token_Request request (token_->type (), this->type (), - ACE_Token_Request::RELEASE, + ACE_Token_Request::RELEASE, this->name (), - this->client_id (), + this->client_id (), options); int result = this->request_reply (request, options); @@ -351,7 +351,7 @@ ACE_Remote_Token_Proxy::release (ACE_Synch_Options &options) return result; } -int +int ACE_Remote_Token_Proxy::remove (ACE_Synch_Options &) { ACE_TRACE ("ACE_Remote_Token_Proxy::remove"); @@ -383,11 +383,11 @@ ACE_Remote_Token_Proxy::dump (void) const ACE_TRACE ("ACE_Remote_Token_Proxy::owner_id"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "ACE_Tokens::dump:\n" - " ignore_shadow_deadlock_ = %d\n", + " ignore_shadow_deadlock_ = %d\n", ignore_shadow_deadlock_)); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Token_Proxy::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } // ************************************************************ @@ -402,7 +402,7 @@ ACE_Remote_Mutex::dump (void) const ACE_DEBUG ((LM_DEBUG, "ACE_Remote_Mutex::dump:\n")); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Remote_Token_Proxy::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } // ************************************************************ @@ -417,7 +417,7 @@ ACE_Remote_RLock::dump (void) const ACE_DEBUG ((LM_DEBUG, "ACE_Remote_RLock::dump:\n")); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Remote_Token_Proxy::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } // ************************************************************ @@ -432,11 +432,15 @@ ACE_Remote_WLock::dump (void) const ACE_DEBUG ((LM_DEBUG, "ACE_Remote_WLock::dump:\n")); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Remote_Token_Proxy::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_TSS <ACE_SOCK_Stream>; template class ACE_Singleton <ACE_TSS_Connection, ACE_TSS_CONNECTION_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_TSS <ACE_SOCK_Stream> +#pragma instantiate ACE_Singleton <ACE_TSS_Connection, ACE_TSS_CONNECTION_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 4e9429b6a11..9958af3ee82 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -46,7 +46,7 @@ ACE_Sig_Adapter ACE_Service_Config::signal_handler_ (&ACE_Service_Config::handle // Trigger a reconfiguration. sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0; - // = Set by command-line options. + // = Set by command-line options. char ACE_Service_Config::debug_ = 0; char ACE_Service_Config::be_a_daemon_ = 0; char ACE_Service_Config::no_static_svcs_ = 0; @@ -54,7 +54,7 @@ char ACE_Service_Config::no_static_svcs_ = 0; // Number of the signal used to trigger reconfiguration. int ACE_Service_Config::signum_ = SIGHUP; -// Name of the service configuration file. +// Name of the service configuration file. const char *ACE_Service_Config::service_config_file_ = ACE_DEFAULT_SVC_CONF; // Name of file used to store messages. @@ -189,7 +189,7 @@ ACE_Service_Config::suspend (const char svc_name[]) } // Resume a SVC_NAME that was previously suspended or has not yet -// been resumed (e.g., a static service). +// been resumed (e.g., a static service). int ACE_Service_Config::resume (const char svc_name[]) @@ -201,10 +201,10 @@ ACE_Service_Config::resume (const char svc_name[]) // Initialize the Service Repository. Note that this *must* // be performed in the constructor (rather than open()) since // otherwise the repository will not be properly initialized -// to allow static configuration of services... +// to allow static configuration of services... -ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs, - size_t size, +ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs, + size_t size, int signum) { ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); @@ -223,7 +223,7 @@ ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs, #if !defined (ACE_LACKS_UNIX_SIGNALS) // This really ought to be a Singleton I suspect... - if (ACE_Reactor::instance ()->register_handler (ACE_Service_Config::signum_, + if (ACE_Reactor::instance ()->register_handler (ACE_Service_Config::signum_, &ACE_Service_Config::signal_handler_) == -1) ACE_ERROR ((LM_ERROR, "can't register signal handler\n")); #endif /* ACE_LACKS_UNIX_SIGNALS */ @@ -244,7 +244,7 @@ ACE_Service_Config::parse_args (int argc, char *argv[]) case 'b': ACE_Service_Config::be_a_daemon_ = 1; break; - case 'd': + case 'd': ACE_Service_Config::debug_ = 1; break; case 'f': @@ -260,8 +260,8 @@ ACE_Service_Config::parse_args (int argc, char *argv[]) #if !defined (ACE_LACKS_UNIX_SIGNALS) ACE_Service_Config::signum_ = ACE_OS::atoi (getopt.optarg); - if (ACE_Reactor::instance()->register_handler - (ACE_Service_Config::signum_, + if (ACE_Reactor::instance()->register_handler + (ACE_Service_Config::signum_, &ACE_Service_Config::signal_handler_) == -1) ACE_ERROR ((LM_ERROR, "cannot obtain signal handler\n")); #endif /* ACE_LACKS_UNIX_SIGNALS */ @@ -273,10 +273,10 @@ ACE_Service_Config::parse_args (int argc, char *argv[]) } } -// Initialize and activate a statically linked service. +// Initialize and activate a statically linked service. int -ACE_Service_Config::initialize (const char svc_name[], +ACE_Service_Config::initialize (const char svc_name[], char *parameters) { ACE_TRACE ("ACE_Service_Config::initialize"); @@ -285,12 +285,12 @@ ACE_Service_Config::initialize (const char svc_name[], ACE_DEBUG ((LM_DEBUG, "opening static service %s\n", svc_name)); - if (ACE_Service_Repository::instance()->find (svc_name, + if (ACE_Service_Repository::instance()->find (svc_name, (const ACE_Service_Record **) &srp) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%s not found\n", svc_name), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%s not found\n", svc_name), -1); else if (srp->type ()->init (args.argc (), args.argv ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "static initialization failed, %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "static initialization failed, %p\n", svc_name), -1); else { @@ -315,7 +315,7 @@ ACE_Service_Config::initialize (const ACE_Service_Record *sr, ACE_ERROR_RETURN ((LM_ERROR, "insertion failed, %p\n", sr->name ()), -1); else if (sr->type ()->init (args.argc (), args.argv ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "dynamic initialization failed for %s\n", + ACE_ERROR_RETURN ((LM_ERROR, "dynamic initialization failed for %s\n", sr->name ()), -1); else return 0; @@ -324,7 +324,7 @@ ACE_Service_Config::initialize (const ACE_Service_Record *sr, // Process service configuration requests as indicated in the // <service_config_file>. -int +int ACE_Service_Config::process_directives (void) { ACE_TRACE ("ACE_Service_Config::process_directives"); @@ -342,7 +342,7 @@ ACE_Service_Config::process_directives (void) ace_yyerrno = 0; ace_yylineno = 1; - + // Use an auto_ptr to make sure that we release this memory // regardless of how we exit... ACE_NEW_RETURN (ace_obstack, ACE_Obstack, -1); @@ -353,7 +353,7 @@ ACE_Service_Config::process_directives (void) if (ace_yyerrno > 0) { - errno = EINVAL; // This is a hack, better errors should be provided... + errno = EINVAL; // This is a hack, better errors should be provided... return ace_yyerrno; } else @@ -378,17 +378,17 @@ ACE_Service_Config::load_static_svcs (void) { ACE_Static_Svc_Descriptor *ssd = *ssdp; - ACE_Service_Type *stp = - ace_create_service_type (ssd->name_, - ssd->type_, - (const void *) (*ssd->alloc_)(), + ACE_Service_Type *stp = + ace_create_service_type (ssd->name_, + ssd->type_, + (const void *) (*ssd->alloc_)(), ssd->flags_); if (stp == 0) continue; ACE_Service_Record *sr; - ACE_NEW_RETURN (sr, ACE_Service_Record (ssd->name_, stp, + ACE_NEW_RETURN (sr, ACE_Service_Record (ssd->name_, stp, 0, ssd->active_), -1); if (ACE_Service_Repository::instance()->insert (sr) == -1) @@ -401,15 +401,15 @@ ACE_Service_Config::load_static_svcs (void) int ACE_Service_Config::open (const char program_name[]) -{ +{ ACE_TRACE ("ACE_Service_Config::open"); // Become a daemon before doing anything else. if (ACE_Service_Config::be_a_daemon_) - ACE_Service_Config::start_daemon (); + ACE_Service_Config::start_daemon (); // Only use STDERR if the users hasn't already set the flags. - if (ACE_LOG_MSG->open (program_name, + if (ACE_LOG_MSG->open (program_name, ACE_LOG_MSG->flags () ? ACE_LOG_MSG->flags () : (u_long) ACE_Log_Msg::STDERR, ACE_Service_Config::logger_key_) == -1) return -1; @@ -426,7 +426,7 @@ ACE_Service_Config::open (const char program_name[]) // Register ourselves to receive reconfiguration requests via // signals! - if (ACE_Service_Config::no_static_svcs_ == 0 + if (ACE_Service_Config::no_static_svcs_ == 0 && ACE_Service_Config::load_static_svcs () == -1) return -1; else @@ -437,10 +437,10 @@ ACE_Service_Config::ACE_Service_Config (const char program_name[]) { ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); - if (this->open (program_name) == -1 - && errno != ENOENT) + if (this->open (program_name) == -1 + && errno != ENOENT) // Only print out an error if it wasn't the svc.conf file that was - // missing. + // missing. ACE_ERROR ((LM_ERROR, "%p\n", program_name)); } @@ -452,8 +452,8 @@ ACE_Service_Config::handle_signal (int sig, siginfo_t *, ucontext_t *) ACE_TRACE ("ACE_Service_Config::handle_signal"); if (ACE_Service_Config::signum_ != sig) - ACE_ERROR ((LM_ERROR, - "error, signal %S does match %S\n", + ACE_ERROR ((LM_ERROR, + "error, signal %S does match %S\n", sig, ACE_Service_Config::signum_)); if (ACE_Service_Config::debug_) @@ -566,9 +566,9 @@ ACE_Service_Config::close_singletons (void) return 0; } -// Perform user-specified close activities and remove dynamic memory. +// Perform user-specified close activities and remove dynamic memory. + - ACE_Service_Config::~ACE_Service_Config (void) { ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config"); @@ -664,7 +664,7 @@ ACE_Service_Config::start_daemon (void) return ACE::daemonize (); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Node<ACE_Static_Svc_Descriptor *>; template class ACE_Unbounded_Set<ACE_Static_Svc_Descriptor *>; template class ACE_Unbounded_Set_Iterator<ACE_Static_Svc_Descriptor *>; @@ -672,4 +672,13 @@ template class ACE_Malloc<ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex>; template class ACE_Allocator_Adapter<ACE_Malloc<ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> >; template class auto_ptr<ACE_Obstack>; template class auto_basic_ptr<ACE_Obstack>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Node<ACE_Static_Svc_Descriptor *> +#pragma instantiate ACE_Unbounded_Set<ACE_Static_Svc_Descriptor *> +#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Static_Svc_Descriptor *> +#pragma instantiate ACE_Malloc<ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> +#pragma instantiate ACE_Allocator_Adapter<ACE_Malloc<ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> > +#pragma instantiate auto_ptr<ACE_Obstack> +#pragma instantiate auto_basic_ptr<ACE_Obstack> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Service_Record.cpp b/ace/Service_Record.cpp index a2534c7a6a4..d6bd5b0e453 100644 --- a/ace/Service_Record.cpp +++ b/ace/Service_Record.cpp @@ -8,8 +8,8 @@ #include "ace/Service_Record.i" #endif /* __ACE_INLINE__ */ -ACE_Service_Object_Type::ACE_Service_Object_Type (ACE_Service_Object *so, - const char *s_name, +ACE_Service_Object_Type::ACE_Service_Object_Type (ACE_Service_Object *so, + const char *s_name, unsigned int f) : ACE_Service_Type ((const void *) so, s_name, f) { @@ -37,8 +37,8 @@ ACE_Module_Type::dump (void) const ACE_TRACE ("ACE_Module_Type::dump"); } -ACE_Module_Type::ACE_Module_Type (MT_Module *m, - const char *m_name, +ACE_Module_Type::ACE_Module_Type (MT_Module *m, + const char *m_name, u_int f) : ACE_Service_Type ((const void *) m, m_name, f) { @@ -114,7 +114,7 @@ ACE_Module_Type::fini (void) const // Close the module and delete the memory. mod->close (MT_Module::M_DELETE); - return ACE_Service_Type::fini (); + return ACE_Service_Type::fini (); } int @@ -181,10 +181,10 @@ ACE_Stream_Type::resume (void) const return 0; } -ACE_Stream_Type::ACE_Stream_Type (MT_Stream *s, - const char *s_name, +ACE_Stream_Type::ACE_Stream_Type (MT_Stream *s, + const char *s_name, unsigned int f) - : ACE_Service_Type ((const void *) s, s_name, f), + : ACE_Service_Type ((const void *) s, s_name, f), head_ (0) { ACE_TRACE ("ACE_Stream_Type::ACE_Stream_Type"); @@ -249,16 +249,16 @@ ACE_Stream_Type::remove (ACE_Module_Type *mod) { if (prev == 0) this->head_ = next; - else + else prev->link (next); // Final arg is an indication to *not* delete the Module. if (str->remove (m->name (), MT_Module::M_DELETE_NONE) == -1) - result = -1; + result = -1; // This call may end up deleting m, which is ok since we // don't access it again! - m->fini (); + m->fini (); } else prev = m; @@ -287,8 +287,8 @@ ACE_Stream_Type::find (const char *mod_name) const { ACE_TRACE ("ACE_Stream_Type::find"); - for (ACE_Module_Type *m = this->head_; - m != 0; + for (ACE_Module_Type *m = this->head_; + m != 0; m = m->link ()) if (ACE_OS::strcmp (m->name (), mod_name) == 0) return m; @@ -304,13 +304,13 @@ ACE_Service_Record::dump (void) const ACE_TRACE ("ACE_Service_Record::dump"); } -ACE_Service_Record::ACE_Service_Record (const char *n, - ACE_Service_Type *t, - const ACE_SHLIB_HANDLE h, +ACE_Service_Record::ACE_Service_Record (const char *n, + ACE_Service_Type *t, + const ACE_SHLIB_HANDLE h, int active) : name_ (0), - type_ (t), - handle_ (h), + type_ (t), + handle_ (h), active_ (active) { ACE_TRACE ("ACE_Service_Record::ACE_Service_Record"); @@ -326,7 +326,7 @@ ACE_Service_Record::~ACE_Service_Record (void) delete [] (char *) this->name_; } -void +void ACE_Service_Record::suspend (void) const { ACE_TRACE ("ACE_Service_Record::suspend"); @@ -334,7 +334,7 @@ ACE_Service_Record::suspend (void) const this->type_->suspend (); } -void +void ACE_Service_Record::resume (void) const { ACE_TRACE ("ACE_Service_Record::resume"); @@ -353,7 +353,7 @@ ACE_Service_Object_Type::fini (void) const return ACE_Service_Type::fini (); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Message_Queue<ACE_SYNCH>; template class ACE_Module<ACE_SYNCH>; template class ACE_Stream<ACE_SYNCH>; @@ -369,4 +369,21 @@ template class ACE_Thru_Task<ACE_SYNCH>; template class ACE_Task<ACE_NULL_SYNCH>; template class ACE_Thru_Task<ACE_NULL_SYNCH>; #endif /* ACE_HAS_THREADS */ -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Message_Queue<ACE_SYNCH> +#pragma instantiate ACE_Module<ACE_SYNCH> +#pragma instantiate ACE_Stream<ACE_SYNCH> +#pragma instantiate ACE_Stream_Head<ACE_SYNCH> +#pragma instantiate ACE_Stream_Tail<ACE_SYNCH> +#pragma instantiate ACE_Task<ACE_SYNCH> +#pragma instantiate ACE_Thru_Task<ACE_SYNCH> + +// Even with threads, these ACE_NULL_SYNCH specializations are necessary. +#if defined (ACE_HAS_THREADS) + #pragma instantiate ACE_Message_Queue<ACE_NULL_SYNCH> + #pragma instantiate ACE_Module<ACE_NULL_SYNCH> + #pragma instantiate ACE_Task<ACE_NULL_SYNCH> + #pragma instantiate ACE_Thru_Task<ACE_NULL_SYNCH> +#endif /* ACE_HAS_THREADS */ +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Signal.cpp b/ace/Signal.cpp index ad96314cc5a..b1b7a2315d8 100644 --- a/ace/Signal.cpp +++ b/ace/Signal.cpp @@ -12,7 +12,7 @@ // Static definitions. #if defined (ACE_HAS_SIG_C_FUNC) -extern "C" void +extern "C" void ace_sig_handler_dispatch (int signum, siginfo_t *info, ucontext_t *context) { ACE_TRACE ("ace_signal_handler_dispatch"); @@ -22,7 +22,7 @@ ace_sig_handler_dispatch (int signum, siginfo_t *info, ucontext_t *context) static ACE_SignalHandler ace_signal_handler_dispatcher = ACE_SignalHandler (ace_sig_handler_dispatch); #if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) -extern "C" void +extern "C" void ace_sig_handlers_dispatch (int signum, siginfo_t *info, ucontext_t *context) { ACE_TRACE ("ace_signal_handlers_dispatch"); @@ -100,9 +100,9 @@ ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, else this->sa_.sa_mask = *sig_mask; // Structure assignment... -#if !defined(ACE_HAS_TANDEM_SIGNALS) +#if !defined(ACE_HAS_TANDEM_SIGNALS) this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); -#else +#else this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); #endif /* !ACE_HAS_TANDEM_SIGNALS */ } @@ -120,9 +120,9 @@ ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, else this->sa_.sa_mask = *sig_mask; // Structure assignment... -#if !defined(ACE_HAS_TANDEM_SIGNALS) +#if !defined(ACE_HAS_TANDEM_SIGNALS) this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); -#else +#else this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); #endif /* !ACE_HAS_TANDEM_SIGNALS */ ACE_OS::sigaction (signum, &this->sa_, 0); @@ -144,7 +144,7 @@ ACE_Sig_Handler::sig_pending (void) return ACE_Sig_Handler::sig_pending_; } -void +void ACE_Sig_Handler::sig_pending (sig_atomic_t pending) { ACE_TRACE ("ACE_Sig_Handler::sig_pending"); @@ -172,9 +172,9 @@ ACE_Sig_Handler::handler (int signum, ACE_Event_Handler *new_sh) if (ACE_Sig_Handler::in_range (signum)) { - ACE_Event_Handler *sh = ACE_Sig_Handler::signal_handlers_[signum]; + ACE_Event_Handler *sh = ACE_Sig_Handler::signal_handlers_[signum]; - ACE_Sig_Handler::signal_handlers_[signum] = new_sh; + ACE_Sig_Handler::signal_handlers_[signum] = new_sh; return sh; } else @@ -184,9 +184,9 @@ ACE_Sig_Handler::handler (int signum, ACE_Event_Handler *new_sh) // Register an ACE_Event_Handler along with the corresponding SIGNUM. int -ACE_Sig_Handler::register_handler (int signum, - ACE_Event_Handler *new_sh, - ACE_Sig_Action *new_disp, +ACE_Sig_Handler::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, ACE_Event_Handler **old_sh, ACE_Sig_Action *old_disp) { @@ -196,18 +196,18 @@ ACE_Sig_Handler::register_handler (int signum, if (ACE_Sig_Handler::in_range (signum)) { ACE_Sig_Action sa; // Define a "null" action. - ACE_Event_Handler *sh = this->handler (signum, new_sh); + ACE_Event_Handler *sh = this->handler (signum, new_sh); // Stack the old ACE_Sig_Handler if the user gives us a pointer - // to a object. + // to a object. if (old_sh != 0) *old_sh = sh; // Make sure that new_disp points to a valid location if the - // user doesn't care... + // user doesn't care... if (new_disp == 0) new_disp = &sa; - + new_disp->handler (ace_signal_handler_dispatcher); new_disp->flags (new_disp->flags () | SA_SIGINFO); return new_disp->register_action (signum, old_disp); @@ -219,7 +219,7 @@ ACE_Sig_Handler::register_handler (int signum, // Remove an ACE_Event_Handler. int -ACE_Sig_Handler::remove_handler (int signum, +ACE_Sig_Handler::remove_handler (int signum, ACE_Sig_Action *new_disp, ACE_Sig_Action *old_disp, int) @@ -247,8 +247,8 @@ ACE_Sig_Handler::remove_handler (int signum, // dispatches one handler... void -ACE_Sig_Handler::dispatch (int signum, - siginfo_t *siginfo, +ACE_Sig_Handler::dispatch (int signum, + siginfo_t *siginfo, ucontext_t *ucontext) { ACE_TRACE ("ACE_Sig_Handler::dispatch"); @@ -262,12 +262,12 @@ ACE_Sig_Handler::dispatch (int signum, // Darn well better be in range since the OS dispatched this... ACE_ASSERT (ACE_Sig_Handler::in_range (signum)); - ACE_Event_Handler *eh = ACE_Sig_Handler::signal_handlers_[signum]; + ACE_Event_Handler *eh = ACE_Sig_Handler::signal_handlers_[signum]; if (eh != 0 && eh->handle_signal (signum, siginfo, ucontext) == -1) { // Define the default disposition. - ACE_Sig_Action sa (SIG_DFL); + ACE_Sig_Action sa (SIG_DFL); ACE_Sig_Handler::signal_handlers_[signum] = 0; @@ -314,8 +314,8 @@ ACE_Sig_Adapter::sigkey (void) } int -ACE_Sig_Adapter::handle_signal (int signum, - siginfo_t *siginfo, +ACE_Sig_Adapter::handle_signal (int signum, + siginfo_t *siginfo, ucontext_t *ucontext) { ACE_TRACE ("ACE_Sig_Adapter::handle_signal"); @@ -364,20 +364,20 @@ ACE_Sig_Adapter::handle_signal (int signum, int ACE_Sig_Handlers::sigkey_ = 0; // If this is > 0 then a 3rd party library has registered a -// handler... +// handler... int ACE_Sig_Handlers::third_party_sig_handler_ = 0; // Make life easier by defining typedefs... -typedef ACE_Fixed_Set <ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> +typedef ACE_Fixed_Set <ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> ACE_SIG_HANDLERS_SET; -typedef ACE_Fixed_Set_Iterator <ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> +typedef ACE_Fixed_Set_Iterator <ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> ACE_SIG_HANDLERS_ITERATOR; class ACE_Sig_Handlers_Set { public: static ACE_SIG_HANDLERS_SET *instance (int signum); - + private: static ACE_SIG_HANDLERS_SET *sig_handlers_[NSIG]; }; @@ -410,9 +410,9 @@ ACE_Sig_Handlers::dump (void) const // (beckerd@erlh.siemens.de). int -ACE_Sig_Handlers::register_handler (int signum, - ACE_Event_Handler *new_sh, - ACE_Sig_Action *new_disp, +ACE_Sig_Handlers::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, ACE_Event_Handler **, ACE_Sig_Action *old_disp) { @@ -423,7 +423,7 @@ ACE_Sig_Handlers::register_handler (int signum, { ACE_Sig_Adapter *ace_sig_adapter = 0; // Our signal handler. ACE_Sig_Adapter *extern_sh = 0; // An external signal handler. - ACE_Sig_Action sa; + ACE_Sig_Action sa; // Get current signal disposition. sa.retrieve_action (signum); @@ -444,7 +444,7 @@ ACE_Sig_Handlers::register_handler (int signum, && ACE_Sig_Handlers::third_party_sig_handler_) // Toggling is disallowed since we might break 3rd party // code. - return -1; + return -1; // Note that we've seen a 3rd party handler... ACE_Sig_Handlers::third_party_sig_handler_ = 1; @@ -528,7 +528,7 @@ ACE_Sig_Handlers::register_handler (int signum, // -1 if <signum> is invalid. int -ACE_Sig_Handlers::remove_handler (int signum, +ACE_Sig_Handlers::remove_handler (int signum, ACE_Sig_Action *new_disp, ACE_Sig_Action *old_disp, int sigkey) @@ -545,8 +545,8 @@ ACE_Sig_Handlers::remove_handler (int signum, // Iterate through the set of handlers for this signal. - for (ACE_Event_Handler **eh; - handler_iterator.next (eh) != 0; + for (ACE_Event_Handler **eh; + handler_iterator.next (eh) != 0; handler_iterator.advance ()) { // Type-safe downcast would be nice here... @@ -586,8 +586,8 @@ ACE_Sig_Handlers::remove_handler (int signum, // dispatches *all* the handlers... void -ACE_Sig_Handlers::dispatch (int signum, - siginfo_t *siginfo, +ACE_Sig_Handlers::dispatch (int signum, + siginfo_t *siginfo, ucontext_t *ucontext) { ACE_TRACE ("ACE_Sig_Handlers::dispatch"); @@ -607,7 +607,7 @@ ACE_Sig_Handlers::dispatch (int signum, ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set); for (ACE_Event_Handler **eh = 0; - handler_iterator.next (eh) != 0; + handler_iterator.next (eh) != 0; handler_iterator.advance ()) { if ((*eh)->handle_signal (signum, siginfo, ucontext) == -1) @@ -668,10 +668,18 @@ ACE_Sig_Handlers::handler (int signum, ACE_Event_Handler *new_sh) return *eh; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) ACE_MT (template class ACE_TSS_Guard<ACE_Recursive_Thread_Mutex>); ACE_MT (template class ACE_Guard<ACE_Recursive_Thread_Mutex>); template class ACE_Fixed_Set<ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS>; template class ACE_Fixed_Set_Iterator<ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#pragma instantiate ACE_TSS_Guard<ACE_Recursive_Thread_Mutex> +#pragma instantiate ACE_Guard<ACE_Recursive_Thread_Mutex> +#endif /* ACE_MT_SAFE */ +#pragma instantiate ACE_Fixed_Set<ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> +#pragma instantiate ACE_Fixed_Set_Iterator<ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ diff --git a/ace/Synch.cpp b/ace/Synch.cpp index 62cd07b8016..8401788fae4 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -44,9 +44,9 @@ ACE_TSS_C_cleanup (void *object) { ACE_TSS_Adapter *tss_adapter = (ACE_TSS_Adapter *) object; // Perform cleanup on the real TS object. - tss_adapter->cleanup (); + tss_adapter->cleanup (); // Delete the adapter object. - delete tss_adapter; + delete tss_adapter; } } @@ -86,35 +86,35 @@ ACE_Process_Mutex::~ACE_Process_Mutex (void) } // Explicitly destroy the mutex. -int +int ACE_Process_Mutex::remove (void) { return this->lock_->remove (); } // Acquire lock ownership (wait on priority queue if necessary). -int +int ACE_Process_Mutex::acquire (void) { return this->lock_->acquire (); } // Conditionally acquire lock (i.e., don't wait on queue). -int +int ACE_Process_Mutex::tryacquire (void) { return this->lock_->tryacquire (); } // Release lock and unblock a thread at head of priority queue. -int +int ACE_Process_Mutex::release (void) { return this->lock_->release (); } // Acquire lock ownership (wait on priority queue if necessary). -int +int ACE_Process_Mutex::acquire_read (void) { return this->lock_->acquire_read (); @@ -127,20 +127,20 @@ int ACE_Process_Mutex::acquire_write (void) } // Conditionally acquire a lock (i.e., won't block). -int +int ACE_Process_Mutex::tryacquire_read (void) { return this->lock_->tryacquire_read (); } // Conditionally acquire a lock (i.e., won't block). -int +int ACE_Process_Mutex::tryacquire_write (void) { return this->lock_->tryacquire_write (); } -ACE_RW_Process_Mutex::ACE_RW_Process_Mutex (LPCTSTR name, +ACE_RW_Process_Mutex::ACE_RW_Process_Mutex (LPCTSTR name, void *arg) : ACE_Process_Mutex (name, arg) { @@ -189,14 +189,14 @@ ACE_Semaphore::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -ACE_Semaphore::ACE_Semaphore (u_int count, - int type, - LPCTSTR name, +ACE_Semaphore::ACE_Semaphore (u_int count, + int type, + LPCTSTR name, void *arg, int max) { // ACE_TRACE ("ACE_Semaphore::ACE_Semaphore"); - if (ACE_OS::sema_init (&this->semaphore_, count, type, + if (ACE_OS::sema_init (&this->semaphore_, count, type, name, arg, max) != 0) ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Semaphore::ACE_Semaphore")); } @@ -225,8 +225,8 @@ ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h) this->set_handle (h); } -ACE_File_Lock::ACE_File_Lock (LPCTSTR name, - int flags, +ACE_File_Lock::ACE_File_Lock (LPCTSTR name, + int flags, mode_t perms) { // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); @@ -236,8 +236,8 @@ ACE_File_Lock::ACE_File_Lock (LPCTSTR name, } int -ACE_File_Lock::open (LPCTSTR name, - int flags, +ACE_File_Lock::open (LPCTSTR name, + int flags, mode_t perms) { // ACE_TRACE ("ACE_File_Lock::open"); @@ -260,8 +260,8 @@ ACE_Process_Semaphore::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count, - LPCTSTR name, +ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count, + LPCTSTR name, void *arg, int max) #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) @@ -284,7 +284,7 @@ ACE_Process_Semaphore::~ACE_Process_Semaphore (void) // Explicitly destroy the semaphore. -int +int ACE_Process_Semaphore::remove (void) { // ACE_TRACE ("ACE_Process_Semaphore::remove"); @@ -294,17 +294,17 @@ ACE_Process_Semaphore::remove (void) // Block the thread until the semaphore count becomes // greater than 0, then decrement it. -int +int ACE_Process_Semaphore::acquire (void) { // ACE_TRACE ("ACE_Process_Semaphore::acquire"); return this->lock_.acquire (); } -// Conditionally decrement the semaphore if count is greater +// Conditionally decrement the semaphore if count is greater // than 0 (i.e., won't block). -int +int ACE_Process_Semaphore::tryacquire (void) { // ACE_TRACE ("ACE_Process_Semaphore::tryacquire"); @@ -314,7 +314,7 @@ ACE_Process_Semaphore::tryacquire (void) // Increment the semaphore, potentially unblocking // a waiting thread. -int +int ACE_Process_Semaphore::release (void) { // ACE_TRACE ("ACE_Process_Semaphore::release"); @@ -347,16 +347,16 @@ ACE_Mutex::~ACE_Mutex (void) this->remove (); } -ACE_Event::ACE_Event (int manual_reset, +ACE_Event::ACE_Event (int manual_reset, int initial_state, - int type, + int type, LPCTSTR name, void *arg) { if (ACE_OS::event_init (&this->handle_, - manual_reset, + manual_reset, initial_state, - type, + type, name, arg) != 0) ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Event::ACE_Event")); @@ -367,50 +367,50 @@ ACE_Event::~ACE_Event (void) this->remove (); } -int +int ACE_Event::remove (void) { return ACE_OS::event_destroy (&this->handle_); } -ACE_event_t +ACE_event_t ACE_Event::handle (void) const { return this->handle_; } void -ACE_Event::handle (ACE_event_t new_handle) +ACE_Event::handle (ACE_event_t new_handle) { this->handle_ = new_handle; } -int +int ACE_Event::wait (void) { return ACE_OS::event_wait (&this->handle_); } -int +int ACE_Event::wait (const ACE_Time_Value *abstime) { return ACE_OS::event_timedwait (&this->handle_, (ACE_Time_Value *) abstime); } -int +int ACE_Event::signal (void) { return ACE_OS::event_signal (&this->handle_); } -int +int ACE_Event::pulse (void) { return ACE_OS::event_pulse (&this->handle_); } -int +int ACE_Event::reset (void) { return ACE_OS::event_reset (&this->handle_); @@ -424,12 +424,12 @@ ACE_Event::dump (void) const } ACE_Manual_Event::ACE_Manual_Event (int initial_state, - int type, + int type, LPCTSTR name, void *arg) : ACE_Event (1, initial_state, - type, + type, name, arg) { @@ -442,12 +442,12 @@ ACE_Manual_Event::dump (void) const } ACE_Auto_Event::ACE_Auto_Event (int initial_state, - int type, + int type, LPCTSTR name, void *arg) : ACE_Event (0, initial_state, - type, + type, name, arg) { @@ -472,8 +472,8 @@ ACE_Thread_Semaphore::dump (void) const ACE_Semaphore::dump (); } -ACE_Thread_Semaphore::ACE_Thread_Semaphore (u_int count, - LPCTSTR name, +ACE_Thread_Semaphore::ACE_Thread_Semaphore (u_int count, + LPCTSTR name, void *arg, int max) : ACE_Semaphore (count, USYNC_THREAD, name, arg, max) @@ -491,7 +491,7 @@ ACE_Thread_Mutex_Guard::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -ACE_thread_t +ACE_thread_t ACE_Recursive_Thread_Mutex::get_thread_id (void) { // ACE_TRACE ("ACE_Recursive_Thread_Mutex::get_thread_id"); @@ -516,7 +516,7 @@ ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex (LPCTSTR name, void *arg) : nesting_mutex_ (name, arg), lock_available_ (nesting_mutex_, name, arg), - nesting_level_ (0), + nesting_level_ (0), owner_id_ (ACE_OS::NULL_thread) { #if defined (ACE_HAS_FSU_PTHREADS) @@ -541,11 +541,11 @@ ACE_Recursive_Thread_Mutex::acquire (void) // Acquire the guard. ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->nesting_mutex_, -1); - + // If there's no contention, just grab the lock immediately (since // this is the common case we'll optimize for it). if (this->nesting_level_ == 0) - this->set_thread_id (t_id); + this->set_thread_id (t_id); // If we already own the lock, then increment the nesting level and // return. else if (ACE_OS::thr_equal (t_id, this->owner_id_) == 0) @@ -556,7 +556,7 @@ ACE_Recursive_Thread_Mutex::acquire (void) this->lock_available_.wait (); // Note that at this point the nesting_mutex_ is held... - this->set_thread_id (t_id); + this->set_thread_id (t_id); } // At this point, we can safely increment the nesting_level_ no @@ -575,7 +575,7 @@ ACE_Recursive_Thread_Mutex::release (void) ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->nesting_mutex_, -1); #if !defined (ACE_NDEBUG) - if (this->nesting_level_ == 0 + if (this->nesting_level_ == 0 || ACE_OS::thr_equal (t_id, this->owner_id_) == 0) { errno = EINVAL; @@ -603,11 +603,11 @@ ACE_Recursive_Thread_Mutex::tryacquire (void) ACE_thread_t t_id = ACE_Thread::self (); ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->nesting_mutex_, -1); - + // If there's no contention, just grab the lock immediately. if (this->nesting_level_ == 0) { - this->set_thread_id (t_id); + this->set_thread_id (t_id); this->nesting_level_ = 1; } // If we already own the lock, then increment the nesting level and @@ -649,7 +649,7 @@ ACE_Condition_Thread_Mutex::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "\n")); #if defined (ACE_WIN32) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "waiters = %d\n", this->cond_.waiters ())); #endif /* ACE_WIN32 */ @@ -670,7 +670,7 @@ ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (const ACE_Thread_Mutex & // ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); if (ACE_OS::cond_init (&this->cond_, USYNC_THREAD, name, arg) != 0) - ACE_ERROR ((LM_ERROR, "%p\n", + ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex")); } @@ -701,7 +701,7 @@ ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex, if (abstime == 0) return ACE_OS::cond_wait (&this->cond_, &mutex_.lock_); else - return ACE_OS::cond_timedwait (&this->cond_, + return ACE_OS::cond_timedwait (&this->cond_, &mutex.lock_, (ACE_Time_Value *) abstime); } @@ -772,7 +772,7 @@ ACE_Barrier::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -ACE_Barrier::ACE_Barrier (u_int count, +ACE_Barrier::ACE_Barrier (u_int count, LPCTSTR name, void *arg) : lock_ (name, arg), @@ -792,7 +792,7 @@ ACE_Barrier::wait (void) // ACE_TRACE ("ACE_Barrier::wait"); ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - ACE_Sub_Barrier *sbp = + ACE_Sub_Barrier *sbp = this->sub_barrier_[this->current_generation_]; // Check for shutdown... @@ -858,7 +858,7 @@ ACE_Process_Condition<MUTEX>::dump (void) const } template <class MUTEX> -ACE_Process_Condition<MUTEX>::ACE_Process_Condition (MUTEX &m, +ACE_Process_Condition<MUTEX>::ACE_Process_Condition (MUTEX &m, LPCTSTR name, void *arg) : ACE_Condition<MUTEX> (m, USYNC_PROCESS, name, arg) @@ -895,7 +895,7 @@ ACE_Thread_Mutex::ACE_Thread_Mutex (LPCTSTR name, void *arg) ACE_ALLOC_HOOK_DEFINE(ACE_RW_Thread_Mutex) -ACE_RW_Thread_Mutex::ACE_RW_Thread_Mutex (LPCTSTR name, +ACE_RW_Thread_Mutex::ACE_RW_Thread_Mutex (LPCTSTR name, void *arg) : ACE_RW_Mutex (USYNC_THREAD, name, arg) { @@ -913,7 +913,7 @@ ACE_RW_Thread_Mutex::dump (void) const #include "ace/Malloc.h" #if defined (ACE_HAS_SIG_C_FUNC) -extern "C" static void +extern "C" static void ace_static_object_lock_atexit (void) { ACE_Static_Object_Lock::atexit (); @@ -943,18 +943,30 @@ ACE_Static_Object_Lock::instance (void) return ACE_Static_Object_Lock::mutex_; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // These are only specialized with ACE_HAS_THREADS. template class ACE_Guard<ACE_SYNCH_RW_MUTEX>; template class ACE_Read_Guard<ACE_SYNCH_RW_MUTEX>; template class ACE_Write_Guard<ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +// These are only specialized with ACE_HAS_THREADS. +#pragma instantiate ACE_Guard<ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Read_Guard<ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Write_Guard<ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // These are specialized both with and without ACE_HAS_THREADS. template class ACE_Guard<ACE_Null_Mutex>; template class ACE_Read_Guard<ACE_Null_Mutex>; template class ACE_Write_Guard<ACE_Null_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +// These are specialized both with and without ACE_HAS_THREADS. +#pragma instantiate ACE_Guard<ACE_Null_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_Null_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_Null_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_SYNCH_C */ diff --git a/ace/System_Time.cpp b/ace/System_Time.cpp index ac2a824b607..dc2389fb5d2 100644 --- a/ace/System_Time.cpp +++ b/ace/System_Time.cpp @@ -6,20 +6,20 @@ ACE_System_Time::ACE_System_Time (LPCTSTR poolname) : delta_time_ (0) -{ +{ ACE_TRACE ("ACE_System_Time::ACE_System_Time"); ACE_NEW (this->shmem_, ALLOCATOR (poolname)); } ACE_System_Time::~ACE_System_Time (void) -{ +{ delete this->shmem_; ACE_TRACE ("ACE_System_Time::~ACE_System_Time"); } // Get the local system time. -int +int ACE_System_Time::get_local_system_time (ACE_UINT32 &time_out) { ACE_TRACE ("ACE_System_Time::get_local_system_time"); @@ -27,7 +27,7 @@ ACE_System_Time::get_local_system_time (ACE_UINT32 &time_out) return 0; } -int +int ACE_System_Time::get_local_system_time (ACE_Time_Value &time_out) { ACE_TRACE ("ACE_System_Time::get_local_system_time"); @@ -37,7 +37,7 @@ ACE_System_Time::get_local_system_time (ACE_Time_Value &time_out) // Get the system time of the central time server. -int +int ACE_System_Time::get_master_system_time (ACE_UINT32 &time_out) { ACE_TRACE ("ACE_System_Time::get_master_system_time"); @@ -76,7 +76,7 @@ ACE_System_Time::get_master_system_time (ACE_UINT32 &time_out) return 0; } -int +int ACE_System_Time::get_master_system_time (ACE_Time_Value &time_out) { ACE_TRACE ("ACE_System_Time::get_master_system_time"); @@ -90,14 +90,18 @@ ACE_System_Time::get_master_system_time (ACE_Time_Value &time_out) // Synchronize local system time with the central time server using // specified mode (currently unimplemented). -int +int ACE_System_Time::sync_local_system_time (ACE_System_Time::Sync_Mode) { ACE_TRACE ("ACE_System_Time::sync_local_system_time"); ACE_NOTSUP_RETURN (-1); } -#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_Allocator_Adapter<ACE_Malloc<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_Allocator_Adapter<ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> > +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Task.cpp b/ace/Task.cpp index d0995abe77b..c4ab1a39048 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -10,12 +10,13 @@ #include "ace/Task.i" #endif /* __ACE_INLINE__ */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) || defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #if (defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)) // For template specializations at end of this file. #include "ace/Dynamic.h" #endif /* ACE_HAS_THREADS && ACE_HAS_THREAD_SPECIFIC_STORAGE */ -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#endif /* ACE_HAS_EXPLICT_TEMPLATE_INSTANTIATION */ + #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) // Lock the creation of the Singleton. @@ -31,7 +32,7 @@ ACE_Task_Exit::instance (void) { ACE_TRACE ("ACE_Task_Exit::instance"); - // Determines if we were dynamically allocated. + // Determines if we were dynamically allocated. static ACE_TSS_TYPE (ACE_Task_Exit) *instance_; // Implement the Double Check pattern. @@ -54,7 +55,7 @@ ACE_Task_Exit::instance (void) // destructor. ACE_Task_Exit::ACE_Task_Exit (void) - : t_ (0), + : t_ (0), status_ ((void *) -1) { ACE_TRACE ("ACE_Task_Exit::ACE_Task_Exit"); @@ -125,7 +126,7 @@ ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man) } // Wait for all threads running in a task to exit. -int +int ACE_Task_Base::wait (void) { ACE_TRACE ("ACE_Task_Base::wait"); @@ -138,7 +139,7 @@ ACE_Task_Base::wait (void) } // Suspend a task. -int +int ACE_Task_Base::suspend (void) { ACE_TRACE ("ACE_Task_Base::suspend"); @@ -150,7 +151,7 @@ ACE_Task_Base::suspend (void) } // Resume a suspended task. -int +int ACE_Task_Base::resume (void) { ACE_TRACE ("ACE_Task_Base::resume"); @@ -162,8 +163,8 @@ ACE_Task_Base::resume (void) } int -ACE_Task_Base::activate (long flags, - int n_threads, +ACE_Task_Base::activate (long flags, + int n_threads, int force_active, long priority, int grp_id, @@ -173,7 +174,7 @@ ACE_Task_Base::activate (long flags, #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - + // If the task passed in is zero, we will use <this> if (task == 0) task = this; @@ -186,12 +187,12 @@ ACE_Task_Base::activate (long flags, // Use the ACE_Thread_Manager singleton if we're running as an // active object and the caller didn't supply us with a // Thread_Manager. - if (this->thr_mgr_ == 0) + if (this->thr_mgr_ == 0) this->thr_mgr_ = ACE_Thread_Manager::instance (); - this->grp_id_ = this->thr_mgr_->spawn_n (n_threads, + this->grp_id_ = this->thr_mgr_->spawn_n (n_threads, ACE_THR_FUNC (&ACE_Task_Base::svc_run), - (void *) this, + (void *) this, flags, priority, grp_id, @@ -280,16 +281,23 @@ ACE_Task_Base::svc_run (void *args) // Forward the call to close() so that existing applications don't // break. -int +int ACE_Task_Base::module_closed (void) { return this->close (1); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) #if (defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)) template class ACE_TSS<ACE_Task_Exit>; // This doesn't necessarily belong here, but it's a convenient place for it. template class ACE_TSS<ACE_Dynamic>; #endif /* ACE_HAS_THREADS && ACE_HAS_THREAD_SPECIFIC_STORAGE */ -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if (defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)) + #pragma instantiate ACE_TSS<ACE_Task_Exit> + // This doesn't necessarily belong here, but it's a convenient place for it. + #pragma instantiate ACE_TSS<ACE_Dynamic> +#endif /* ACE_HAS_THREADS && ACE_HAS_THREAD_SPECIFIC_STORAGE */ +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Timer_Hash.cpp b/ace/Timer_Hash.cpp index 23e6d9082eb..6482e1051d7 100644 --- a/ace/Timer_Hash.cpp +++ b/ace/Timer_Hash.cpp @@ -10,11 +10,11 @@ #include "ace/config.h" #include "ace/Timer_Hash.h" -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Free_List<ACE_Timer_Node_T<ACE_Event_Handler *> >; template class ACE_Locked_Free_List<ACE_Timer_Node_T<ACE_Event_Handler *>, ACE_Null_Mutex>; -template class ACE_Timer_Hash_Upcall <ACE_Event_Handler *, +template class ACE_Timer_Hash_Upcall <ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; @@ -26,7 +26,7 @@ template class ACE_Timer_Queue_Iterator_T <ACE_Event_Handler *, ACE_Hash_Upcall, ACE_Null_Mutex>; -template class ACE_Timer_List_T <ACE_Event_Handler *, +template class ACE_Timer_List_T <ACE_Event_Handler *, ACE_Hash_Upcall, ACE_Null_Mutex>; @@ -34,7 +34,7 @@ template class ACE_Timer_List_Iterator_T <ACE_Event_Handler *, ACE_Hash_Upcall, ACE_Null_Mutex>; -template class ACE_Timer_Heap_T <ACE_Event_Handler *, +template class ACE_Timer_Heap_T <ACE_Event_Handler *, ACE_Hash_Upcall, ACE_Null_Mutex>; @@ -42,26 +42,79 @@ template class ACE_Timer_Heap_Iterator_T <ACE_Event_Handler *, ACE_Hash_Upcall, ACE_Null_Mutex>; -template class ACE_Timer_Hash_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, +template class ACE_Timer_Hash_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX, ACE_Hash_Timer_List>; -template class ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, +template class ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX, ACE_Hash_Timer_List>; -template class ACE_Timer_Hash_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, +template class ACE_Timer_Hash_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX, ACE_Hash_Timer_Heap>; -template class ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, +template class ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX, ACE_Hash_Timer_Heap>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Free_List<ACE_Timer_Node_T<ACE_Event_Handler *> > +#pragma instantiate ACE_Locked_Free_List<ACE_Timer_Node_T<ACE_Event_Handler *>, \ + ACE_Null_Mutex> +#pragma instantiate ACE_Timer_Hash_Upcall <ACE_Event_Handler *, \ + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, \ + ACE_SYNCH_RECURSIVE_MUTEX> + +#pragma instantiate ACE_Timer_Queue_T <ACE_Event_Handler *, \ + ACE_Hash_Upcall, \ + ACE_Null_Mutex> + +#pragma instantiate ACE_Timer_Queue_Iterator_T <ACE_Event_Handler *, \ + ACE_Hash_Upcall, \ + ACE_Null_Mutex> + +#pragma instantiate ACE_Timer_List_T <ACE_Event_Handler *, \ + ACE_Hash_Upcall, \ + ACE_Null_Mutex> + +#pragma instantiate ACE_Timer_List_Iterator_T <ACE_Event_Handler *, \ + ACE_Hash_Upcall, \ + ACE_Null_Mutex> + +#pragma instantiate ACE_Timer_Heap_T <ACE_Event_Handler *, \ + ACE_Hash_Upcall, \ + ACE_Null_Mutex> + +#pragma instantiate ACE_Timer_Heap_Iterator_T <ACE_Event_Handler *, \ + ACE_Hash_Upcall, \ + ACE_Null_Mutex> + +#pragma instantiate ACE_Timer_Hash_T<ACE_Event_Handler *, \ + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, \ + ACE_SYNCH_RECURSIVE_MUTEX, \ + ACE_Hash_Timer_List> + +#pragma instantiate ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *, \ + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, \ + ACE_SYNCH_RECURSIVE_MUTEX, \ + ACE_Hash_Timer_List> + +#pragma instantiate ACE_Timer_Hash_T<ACE_Event_Handler *, \ + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, \ + ACE_SYNCH_RECURSIVE_MUTEX, \ + ACE_Hash_Timer_Heap> + +#pragma instantiate ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *, \ + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, \ + ACE_SYNCH_RECURSIVE_MUTEX, \ + ACE_Hash_Timer_Heap> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_TIMER_HASH_C */ diff --git a/ace/Timer_Heap.cpp b/ace/Timer_Heap.cpp index 9f3202c3d4d..7f18e85a699 100644 --- a/ace/Timer_Heap.cpp +++ b/ace/Timer_Heap.cpp @@ -8,9 +8,13 @@ #include "ace/config.h" #include "ace/Timer_Heap.h" -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#pragma instantiate ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_TIMER_HEAP_C */ diff --git a/ace/Timer_List.cpp b/ace/Timer_List.cpp index 3ad874857c1..8bae22eb456 100644 --- a/ace/Timer_List.cpp +++ b/ace/Timer_List.cpp @@ -8,9 +8,13 @@ #include "ace/config.h" #include "ace/Timer_List.h" -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#pragma instantiate ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_TIMER_LIST_C */ diff --git a/ace/Timer_Queue.cpp b/ace/Timer_Queue.cpp index cf3cc833ec0..ff6471efdf8 100644 --- a/ace/Timer_Queue.cpp +++ b/ace/Timer_Queue.cpp @@ -9,13 +9,21 @@ #include "ace/Containers.h" #include "ace/Timer_Queue.h" -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Event_Handler *> *>; template class ACE_Node<ACE_Timer_Node_T<ACE_Event_Handler *> *>; template class ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Event_Handler *> *>; template class ACE_Timer_Node_T<ACE_Event_Handler *>; template class ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Event_Handler *> *> +#pragma instantiate ACE_Node<ACE_Timer_Node_T<ACE_Event_Handler *> *> +#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Event_Handler *> *> +#pragma instantiate ACE_Timer_Node_T<ACE_Event_Handler *> +#pragma instantiate ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#pragma instantiate ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_TIMER_QUEUE_C */ diff --git a/ace/Timer_Wheel.cpp b/ace/Timer_Wheel.cpp index 9366f7ca190..53f1cd236df 100644 --- a/ace/Timer_Wheel.cpp +++ b/ace/Timer_Wheel.cpp @@ -8,9 +8,13 @@ #include "ace/config.h" #include "ace/Timer_Wheel.h" -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Timer_Wheel_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Timer_Wheel_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#pragma instantiate ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_TIMER_WHEEL_C */ diff --git a/ace/Token.cpp b/ace/Token.cpp index 6ab6495501f..1ba979496c3 100644 --- a/ace/Token.cpp +++ b/ace/Token.cpp @@ -20,7 +20,7 @@ ACE_Token::dump (void) const ACE_TRACE ("ACE_Token::dump"); } -ACE_Token::ACE_Queue_Entry::ACE_Queue_Entry (ACE_Thread_Mutex &m, +ACE_Token::ACE_Queue_Entry::ACE_Queue_Entry (ACE_Thread_Mutex &m, ACE_thread_t t_id) : next_ (0), thread_id_ (t_id), @@ -31,10 +31,10 @@ ACE_Token::ACE_Queue_Entry::ACE_Queue_Entry (ACE_Thread_Mutex &m, } ACE_Token::ACE_Token (LPCTSTR name, void *any) - : head_ (0), - tail_ (0), + : head_ (0), + tail_ (0), lock_ (name, any), - in_use_ (0), + in_use_ (0), waiters_ (0), nesting_level_ (0) { @@ -46,7 +46,7 @@ ACE_Token::~ACE_Token (void) ACE_TRACE ("ACE_Token::~ACE_Token"); } -// Remove an entry from the list. Must be +// Remove an entry from the list. Must be // called with locks held. void @@ -65,21 +65,21 @@ ACE_Token::remove_entry (ACE_Token::ACE_Queue_Entry *entry) prev = curr; if (curr == 0) // Didn't find the entry... - return; + return; else if (prev == 0) // Delete at the head. this->head_ = this->head_->next_; else // Delete in the middle. prev->next_ = curr->next_; - // We need to update the tail of the list - // if we've deleted the last entry. + // We need to update the tail of the list + // if we've deleted the last entry. if (curr->next_ == 0) this->tail_ = curr; } -int -ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), +int +ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), void *arg, ACE_Time_Value *timeout) { @@ -96,9 +96,9 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), #endif /* DEBUGGING */ if (this->in_use_) // Someone already holds the token. - { + { if (ACE_OS::thr_equal (thr_id, this->owner_)) // I own it! - { + { this->nesting_level_++; return 0; } @@ -117,7 +117,7 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), int ret = 0; if (this->head_ == 0) // I'm first and only waiter in line... - { + { this->head_ = &my_entry; this->tail_ = &my_entry; } @@ -125,13 +125,13 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), { this->tail_->next_ = &my_entry; this->tail_ = &my_entry; - } + } this->waiters_++; // Execute appropriate <sleep_hook> callback. // (@@ should these methods return a success/failure - // status, and if so, what should we do with it?) + // status, and if so, what should we do with it?) if (sleep_hook_func) { @@ -154,8 +154,8 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), continue; #if defined (DEBUGGING) cerr << '(' << ACE_Thread::self () << ')' - << " acquire: " - << (errno == ETIME ? "timed out" : "error occurred") + << " acquire: " + << (errno == ETIME ? "timed out" : "error occurred") << endl; #endif /* DEBUGGING */ // We come here if a timeout occurs or some serious @@ -175,7 +175,7 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), else { this->in_use_ = 1; - this->owner_ = thr_id; // Its mine! + this->owner_ = thr_id; // Its mine! return 0; } } @@ -189,7 +189,7 @@ ACE_Token::sleep_hook (void) ACE_TRACE ("ACE_Token::sleep_hook"); } -int +int ACE_Token::acquire (ACE_Time_Value *timeout) { ACE_TRACE ("ACE_Token::acquire"); @@ -199,8 +199,8 @@ ACE_Token::acquire (ACE_Time_Value *timeout) // Acquire the token, sleeping until it is obtained or until // <timeout> expires. -int -ACE_Token::acquire (void (*sleep_hook_func)(void *), +int +ACE_Token::acquire (void (*sleep_hook_func)(void *), void *arg, ACE_Time_Value *timeout) { @@ -218,8 +218,8 @@ ACE_Token::renew (int requeue_position, ACE_Time_Value *timeout) #if defined (DEBUGGING) cerr << '(' << ACE_Thread::self () << ')' - << " renew: owner_ thr = " << this->owner_ - << ", owner_ addr = " << &this->owner_ + << " renew: owner_ thr = " << this->owner_ + << ", owner_ addr = " << &this->owner_ << ", nesting level = " << this->nesting_level_ << endl; #endif /* DEBUGGING */ ACE_ASSERT (ACE_OS::thr_equal (ACE_Thread::self (), this->owner_)); @@ -239,11 +239,11 @@ ACE_Token::renew (int requeue_position, ACE_Time_Value *timeout) this->head_ = this->head_->next_; - if (this->head_ == 0) // No other threads - just add me - { + if (this->head_ == 0) // No other threads - just add me + { this->head_ = &my_entry; this->tail_ = &my_entry; - } + } else if (requeue_position == -1) // Insert at the end of the queue. { this->tail_->next_ = &my_entry; @@ -259,7 +259,7 @@ ACE_Token::renew (int requeue_position, ACE_Time_Value *timeout) ACE_Token::ACE_Queue_Entry *insert_after = this->head_; // Determine where our thread should go in the queue of - // waiters. + // waiters. while (requeue_position-- && insert_after->next_ != 0) insert_after = insert_after->next_; @@ -282,10 +282,10 @@ ACE_Token::renew (int requeue_position, ACE_Time_Value *timeout) continue; #if defined (DEBUGGING) cerr << '(' << ACE_Thread::self () << ')' - << " renew: " + << " renew: " << (errno == ETIME ? "timed out" : "error occurred") << endl; #endif /* DEBUGGING */ - // We come here if a timeout occurs or + // We come here if a timeout occurs or // some serious ACE_Condition object error. this->remove_entry (&my_entry); return -1; @@ -311,18 +311,18 @@ ACE_Token::release (void) #if defined (DEBUGGING) cerr << '(' << ACE_Thread::self () << ')' - << " release: owner_ thr = " << this->owner_ - << ", owner_ addr = " << &this->owner_ + << " release: owner_ thr = " << this->owner_ + << ", owner_ addr = " << &this->owner_ << ", nesting level = " << this->nesting_level_ << endl; #endif /* DEBUGGING */ if (this->nesting_level_ > 0) --this->nesting_level_; - else + else { if (this->head_ == 0) this->in_use_ = 0; // No more waiters... - else + else { this->owner_ = this->head_->thread_id_; --this->waiters_; @@ -335,12 +335,14 @@ ACE_Token::release (void) if (this->head_ == 0) this->tail_ = 0; - } + } } return 0; } #endif /* ACE_HAS_THREADS */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Token_Collection.cpp b/ace/Token_Collection.cpp index ac349124673..24025952a41 100644 --- a/ace/Token_Collection.cpp +++ b/ace/Token_Collection.cpp @@ -73,7 +73,7 @@ ACE_Token_Collection::is_member (const ACE_Token_Proxy &token) return collection_.find (token_name) == 0; } -int +int ACE_Token_Collection::acquire (int notify, void (*sleep_hook)(void *), ACE_Synch_Options &options) @@ -101,7 +101,7 @@ ACE_Token_Collection::acquire (int notify, return 0; } -int +int ACE_Token_Collection::acquire (const char *token_name, int notify, void (*sleep_hook)(void *), @@ -120,7 +120,7 @@ ACE_Token_Collection::acquire (const char *token_name, } -int +int ACE_Token_Collection::tryacquire (const char *token_name, void (*sleep_hook)(void *)) { @@ -137,7 +137,7 @@ ACE_Token_Collection::tryacquire (const char *token_name, return temp->tryacquire (sleep_hook); } -int +int ACE_Token_Collection::tryacquire (void (*sleep_hook)(void *)) { ACE_TRACE ("ACE_Token_Collection::tryacquire"); @@ -159,7 +159,7 @@ ACE_Token_Collection::tryacquire (void (*sleep_hook)(void *)) return 0; } -int +int ACE_Token_Collection::renew (int requeue_position, ACE_Synch_Options &options) { @@ -181,7 +181,7 @@ ACE_Token_Collection::renew (int requeue_position, return 0; } -int +int ACE_Token_Collection::renew (const char *token_name, int requeue_position, ACE_Synch_Options &options) @@ -202,7 +202,7 @@ ACE_Token_Collection::renew (const char *token_name, return temp->renew (requeue_position, options); } -int +int ACE_Token_Collection::release (ACE_Synch_Options &) { @@ -222,7 +222,7 @@ ACE_Token_Collection::release (ACE_Synch_Options &) return 0; } -int +int ACE_Token_Collection::release (const char *token_name, ACE_Synch_Options &options) { @@ -281,11 +281,16 @@ ACE_Token_Collection::dump (void) const collection_.dump (); ACE_DEBUG ((LM_DEBUG, "base:\n")); ACE_Token_Proxy::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Map_Manager<ACE_Token_Name, ACE_Token_Proxy *, ACE_Null_Mutex>; template class ACE_Map_Iterator<ACE_Token_Name, ACE_Token_Proxy *, ACE_Null_Mutex>; template class ACE_Map_Entry<ACE_Token_Name, ACE_Token_Proxy *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Map_Manager<ACE_Token_Name, ACE_Token_Proxy *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<ACE_Token_Name, ACE_Token_Proxy *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry<ACE_Token_Name, ACE_Token_Proxy *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Token_Invariants.cpp b/ace/Token_Invariants.cpp index a9a18f7b5f8..098be4fea43 100644 --- a/ace/Token_Invariants.cpp +++ b/ace/Token_Invariants.cpp @@ -47,7 +47,7 @@ ACE_Token_Invariant_Manager::mutex_acquired (const char *token_name) else return inv->acquired (); } - + int ACE_Token_Invariant_Manager::acquired (const ACE_Token_Proxy *proxy) { @@ -64,7 +64,7 @@ ACE_Token_Invariant_Manager::acquired (const ACE_Token_Proxy *proxy) return this->writer_acquired (proxy->name ()); } } - + void ACE_Token_Invariant_Manager::releasing (const ACE_Token_Proxy *proxy) { @@ -76,7 +76,7 @@ ACE_Token_Invariant_Manager::releasing (const ACE_Token_Proxy *proxy) else // ACE_Tokens::RWLOCK. this->rwlock_releasing (proxy->name ()); } - + void ACE_Token_Invariant_Manager::mutex_releasing (const char *token_name) { @@ -136,7 +136,7 @@ ACE_Token_Invariant_Manager::dump (void) const mutex_collection_.dump (); ACE_DEBUG ((LM_DEBUG, "rwlock_collection_:\n")); rwlock_collection_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } @@ -150,7 +150,7 @@ ACE_Token_Invariant_Manager::get_mutex (const char *token_name, // We did not find one in the collection. { ACE_Mutex_Invariants *new_invariant; - + ACE_NEW_RETURN (new_invariant, ACE_Mutex_Invariants, -1); if (mutex_collection_.bind (name, new_invariant) == -1) @@ -177,7 +177,7 @@ ACE_Token_Invariant_Manager::get_rwlock (const char *token_name, // We did not find one in the collection. { ACE_RWLock_Invariants *new_invariant; - + ACE_NEW_RETURN (new_invariant, ACE_RWLock_Invariants, -1); if (rwlock_collection_.bind (name, new_invariant) == -1) @@ -219,7 +219,7 @@ ACE_Mutex_Invariants::ACE_Mutex_Invariants (void) { } -int +int ACE_Mutex_Invariants::acquired (void) { if (++owners_ > 1) @@ -231,7 +231,7 @@ ACE_Mutex_Invariants::acquired (void) return 1; } -void +void ACE_Mutex_Invariants::releasing (void) { if (owners_ == 1) @@ -243,7 +243,7 @@ ACE_Mutex_Invariants::ACE_Mutex_Invariants (const ACE_Mutex_Invariants &rhs) { } -void +void ACE_Mutex_Invariants::operator= (const ACE_Mutex_Invariants &rhs) { owners_ = rhs.owners_; @@ -255,7 +255,7 @@ ACE_Mutex_Invariants::dump (void) const ACE_TRACE ("ACE_Mutex_Invariants::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "owners_ = %d\n", owners_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } // ************************************************** @@ -268,7 +268,7 @@ ACE_RWLock_Invariants::ACE_RWLock_Invariants (void) { } -int +int ACE_RWLock_Invariants::writer_acquired (void) { if (readers_ > 0) @@ -285,7 +285,7 @@ ACE_RWLock_Invariants::writer_acquired (void) return 1; } -int +int ACE_RWLock_Invariants::reader_acquired (void) { if (writers_ > 0) @@ -300,7 +300,7 @@ ACE_RWLock_Invariants::reader_acquired (void) } } -void +void ACE_RWLock_Invariants::releasing (void) { if (writers_ == 1) @@ -315,7 +315,7 @@ ACE_RWLock_Invariants::ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs) { } -void +void ACE_RWLock_Invariants::operator= (const ACE_RWLock_Invariants &rhs) { writers_ = rhs.writers_; @@ -330,14 +330,22 @@ ACE_RWLock_Invariants::dump (void) const ACE_DEBUG ((LM_DEBUG, "writers_ = %d\n", "readers_ = %d\n", writers_, readers_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Map_Manager<ACE_Token_Name, ACE_Mutex_Invariants *, ACE_Null_Mutex>; template class ACE_Map_Iterator<ACE_Token_Name, ACE_Mutex_Invariants *, ACE_Null_Mutex>; template class ACE_Map_Entry<ACE_Token_Name, ACE_Mutex_Invariants *>; template class ACE_Map_Manager<ACE_Token_Name, ACE_RWLock_Invariants *, ACE_Null_Mutex>; template class ACE_Map_Iterator<ACE_Token_Name, ACE_RWLock_Invariants *, ACE_Null_Mutex>; template class ACE_Map_Entry<ACE_Token_Name, ACE_RWLock_Invariants *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Map_Manager<ACE_Token_Name, ACE_Mutex_Invariants *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<ACE_Token_Name, ACE_Mutex_Invariants *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry<ACE_Token_Name, ACE_Mutex_Invariants *> +#pragma instantiate ACE_Map_Manager<ACE_Token_Name, ACE_RWLock_Invariants *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<ACE_Token_Name, ACE_RWLock_Invariants *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry<ACE_Token_Name, ACE_RWLock_Invariants *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ace/Token_Manager.cpp b/ace/Token_Manager.cpp index fcaa86d805c..0a0106e5a5b 100644 --- a/ace/Token_Manager.cpp +++ b/ace/Token_Manager.cpp @@ -48,24 +48,24 @@ ACE_Token_Manager::instance (void) if (token_manager_ == 0) ACE_NEW_RETURN (token_manager_, ACE_Token_Manager, 0); - } + } return token_manager_; } void -ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, - const char *token_name) +ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, + const char *token_name) { ACE_TRACE ("ACE_Token_Manager::get"); // Hmm. I think this makes sense. We perform our own locking here // (see safe_acquire.) We have to make sure that only one thread // uses the collection at a time. - + ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_); TOKEN_NAME name (token_name); - + if (collection_.find (name, proxy->token_) == -1) // We did not find one in the collection. { @@ -84,7 +84,7 @@ ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, proxy->token_->inc_reference (); // We may be returning proxy->token_ == 0 if new failed, caller must - // check. + // check. } // 0. check_deadlock (TOKEN) @@ -97,7 +97,7 @@ ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, // 7. else, if check_deadlock (NEW_TOKEN) == 1, return *DEADLOCK* // 8. return 0. -int +int ACE_Token_Manager::check_deadlock (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Manager::check_deadlock"); @@ -116,7 +116,7 @@ ACE_Token_Manager::check_deadlock (ACE_Token_Proxy *proxy) return result; } -int +int ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Manager::check_deadlock"); @@ -127,7 +127,7 @@ ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) token->visit (1); ACE_Tokens::OWNER_STACK owners; - + int is_owner = token->owners (owners, proxy->client_id ()); switch (is_owner) @@ -140,10 +140,10 @@ ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) if (debug_) { ACE_DEBUG ((LM_DEBUG, "(%t) Deadlock detected.\n")); - ACE_DEBUG ((LM_DEBUG, "%s owns %s and is waiting for %s.\n", + ACE_DEBUG ((LM_DEBUG, "%s owns %s and is waiting for %s.\n", proxy->client_id (), token->name (), - proxy->token_->name ())); + proxy->token_->name ())); } return 1; @@ -161,7 +161,7 @@ ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) { if (debug_) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "%s owns %s and is waiting for %s.\n", e->client_id (), token->name (), @@ -248,11 +248,16 @@ ACE_Token_Manager::dump (void) const lock_.dump (); ACE_DEBUG ((LM_DEBUG, "collection_\n")); collection_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Map_Manager <ACE_Token_Name, ACE_Tokens *, ACE_Null_Mutex>; template class ACE_Map_Iterator<ACE_Token_Name, ACE_Tokens *, ACE_Null_Mutex>; template class ACE_Map_Entry <ACE_Token_Name, ACE_Tokens *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Map_Manager <ACE_Token_Name, ACE_Tokens *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<ACE_Token_Name, ACE_Tokens *, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry <ACE_Token_Name, ACE_Tokens *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Gateway/Config_Files.cpp b/apps/Gateway/Gateway/Config_Files.cpp index feb4d72f010..68d53f4862e 100644 --- a/apps/Gateway/Gateway/Config_Files.cpp +++ b/apps/Gateway/Gateway/Config_Files.cpp @@ -8,8 +8,8 @@ typedef FP::Return_Type FP_RETURN_TYPE; FP_RETURN_TYPE -Consumer_Config_File_Parser::read_entry (Consumer_Config_Info &entry, - int &line_number) +Consumer_Config_File_Parser::read_entry (Consumer_Config_Info &entry, + int &line_number) { FP_RETURN_TYPE read_result; @@ -18,11 +18,11 @@ Consumer_Config_File_Parser::read_entry (Consumer_Config_Info &entry, // Ignore comments, check for EOF and EOLINE if this succeeds, we // have our connection id. - while ((read_result = this->getint (entry.proxy_id_)) != FP::SUCCESS) + while ((read_result = this->getint (entry.proxy_id_)) != FP::SUCCESS) { - if (read_result == FP::EOFILE) + if (read_result == FP::EOFILE) return FP::EOFILE; - else if (read_result == FP::EOLINE + else if (read_result == FP::EOLINE || read_result == FP::COMMENT) line_number++; } @@ -49,8 +49,8 @@ Consumer_Config_File_Parser::read_entry (Consumer_Config_Info &entry, } FP_RETURN_TYPE -Proxy_Config_File_Parser::read_entry (Proxy_Config_Info &entry, - int &line_number) +Proxy_Config_File_Parser::read_entry (Proxy_Config_Info &entry, + int &line_number) { char buf[BUFSIZ]; FP_RETURN_TYPE read_result; @@ -59,12 +59,12 @@ Proxy_Config_File_Parser::read_entry (Proxy_Config_Info &entry, // Ignore comments, check for EOF and EOLINE // if this succeeds, we have our connection id - while ((read_result = this->getint (entry.proxy_id_)) != FP::SUCCESS) + while ((read_result = this->getint (entry.proxy_id_)) != FP::SUCCESS) { - if (read_result == FP::EOFILE) + if (read_result == FP::EOFILE) return FP::EOFILE; - else if (read_result == FP::EOLINE - || read_result == FP::COMMENT) + else if (read_result == FP::EOLINE + || read_result == FP::COMMENT) line_number++; } @@ -118,7 +118,7 @@ int main (int argc, char *argv[]) FP_RETURN_TYPE result; Proxy_Config_Info entry; Proxy_Config_File_Parser CCfile; - + CCfile.open (argv[1]); int line_number = 0; @@ -131,7 +131,7 @@ int main (int argc, char *argv[]) if (result != FP::SUCCESS) // ACE_DEBUG ((LM_DEBUG, "Error line %d.\n", line_number)); cerr << "Error at line " << line_number << endl; - else + else printf ("%d\t%s\t%d\t%c\t%d\t%c\t%d\n", entry.proxy_id_, entry.host_, entry.remote_port_, entry.proxy_role_, entry.max_retry_timeout_, entry.transform_, entry.local_port_); @@ -152,7 +152,7 @@ int main (int argc, char *argv[]) { if (result != FP::SUCCESS) cerr << "Error at line " << line_number << endl; - else + else { printf ("%d\t%d\t%d\t%d\t", entry.proxy_id_, entry.supplier_id_, entry.type_); @@ -167,7 +167,11 @@ int main (int argc, char *argv[]) } #endif /* DEBUGGING */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class File_Parser<Proxy_Config_Info>; template class File_Parser<Consumer_Config_Info>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate File_Parser<Proxy_Config_Info> +#pragma instantiate File_Parser<Consumer_Config_Info> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Gateway/Event_Channel.cpp b/apps/Gateway/Gateway/Event_Channel.cpp index 412fb12635b..87918b89fc3 100644 --- a/apps/Gateway/Gateway/Event_Channel.cpp +++ b/apps/Gateway/Gateway/Event_Channel.cpp @@ -56,12 +56,12 @@ ACE_Event_Channel::compute_performance_statistics (void) size_t total_bytes_in = 0; size_t total_bytes_out = 0; - + // Iterate through the connection map summing up the number of bytes // sent/received. for (PROXY_MAP_ENTRY *me = 0; - cmi.next (me) != 0; + cmi.next (me) != 0; cmi.advance ()) { Proxy_Handler *proxy_handler = me->int_id_; @@ -73,25 +73,25 @@ ACE_Event_Channel::compute_performance_statistics (void) } #if defined (ACE_NLOGGING) - ACE_OS::fprintf (stderr, + ACE_OS::fprintf (stderr, "After %d seconds, \ntotal_bytes_in = %d\ntotal_bytes_out = %d\n", performance_window_, - total_bytes_in, + total_bytes_in, total_bytes_out); - ACE_OS::fprintf (stderr, "%f Mbits/sec received.\n", + ACE_OS::fprintf (stderr, "%f Mbits/sec received.\n", (float) (total_bytes_in * 8 / (float) (1024*1024*this->performance_window_))); - ACE_OS::fprintf (stderr, "%f Mbits/sec sent.\n", + ACE_OS::fprintf (stderr, "%f Mbits/sec sent.\n", (float) (total_bytes_out * 8 / (float) (1024*1024*this->performance_window_))); #else ACE_DEBUG ((LM_DEBUG, "(%t) after %d seconds, \ntotal_bytes_in = %d\ntotal_bytes_out = %d\n", this->options ().performance_window_, total_bytes_in, total_bytes_out)); - ACE_DEBUG ((LM_DEBUG, "(%t) %f Mbits/sec received.\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %f Mbits/sec received.\n", (float) (total_bytes_in * 8 / (float) (1024 * 1024 * this->options ().performance_window_)))); - ACE_DEBUG ((LM_DEBUG, "(%t) %f Mbits/sec sent.\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %f Mbits/sec sent.\n", (float) (total_bytes_out * 8 / (float) (1024 * 1024 * this->options ().performance_window_)))); #endif /* ACE_NLOGGING */ @@ -108,7 +108,7 @@ ACE_Event_Channel::compute_performance_statistics (void) } int -ACE_Event_Channel::handle_timeout (const ACE_Time_Value &, +ACE_Event_Channel::handle_timeout (const ACE_Time_Value &, const void *) { return this->compute_performance_statistics (); @@ -118,47 +118,47 @@ ACE_Event_Channel::handle_timeout (const ACE_Time_Value &, // to receive it. int -ACE_Event_Channel::put (ACE_Message_Block *event, +ACE_Event_Channel::put (ACE_Message_Block *event, ACE_Time_Value *) { // We got a valid event, so determine its virtual forwarding // address, which is stored in the first of the two event blocks, // which are chained together by this->recv(). - + Event_Key *forwarding_addr = (Event_Key *) event->rd_ptr (); - + // Skip over the address portion and get the data. ACE_Message_Block *data = event->cont (); - + // <dispatch_set> points to the set of Consumers associated with // this forwarding address. Consumer_Dispatch_Set *dispatch_set = 0; - + if (this->efd_.find (*forwarding_addr, dispatch_set) == -1) // Failure. - ACE_ERROR ((LM_DEBUG, + ACE_ERROR ((LM_DEBUG, "(%t) find failed on conn id = %d, supplier id = %d, type = %d\n", - forwarding_addr->proxy_id_, - forwarding_addr->supplier_id_, + forwarding_addr->proxy_id_, + forwarding_addr->supplier_id_, forwarding_addr->type_)); else { // Check to see if there are any consumers. if (dispatch_set->size () == 0) - ACE_DEBUG ((LM_WARNING, + ACE_DEBUG ((LM_WARNING, "there are no active consumers for this event currently\n")); - + else // There are consumers, so forward the event. { Consumer_Dispatch_Set_Iterator dsi (*dispatch_set); - + // At this point, we should assign a thread-safe locking // strategy to the Message_Block is we're running in a // multi-threaded configuration. // data->locking_strategy (MB_Locking_Strategy::instance ()); - for (Proxy_Handler **proxy_handler = 0; - dsi.next (proxy_handler) != 0; + for (Proxy_Handler **proxy_handler = 0; + dsi.next (proxy_handler) != 0; dsi.advance ()) { // Only process active proxy_handlers. @@ -167,19 +167,19 @@ ACE_Event_Channel::put (ACE_Message_Block *event, // Duplicate the event portion via reference // counting. ACE_Message_Block *dup_msg = data->duplicate (); - - ACE_DEBUG ((LM_DEBUG, "(%t) forwarding to Consumer %d\n", + + ACE_DEBUG ((LM_DEBUG, "(%t) forwarding to Consumer %d\n", (*proxy_handler)->id ())); - + if ((*proxy_handler)->put (dup_msg) == -1) { if (errno == EWOULDBLOCK) // The queue has filled up! - ACE_ERROR ((LM_ERROR, "(%t) %p\n", + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "gateway is flow controlled, so we're dropping events")); else ACE_ERROR ((LM_ERROR, "(%t) %p transmission error to peer %d\n", "put", (*proxy_handler)->id ())); - + // We are responsible for releasing an // ACE_Message_Block if failures occur. dup_msg->release (); @@ -204,13 +204,13 @@ int ACE_Event_Channel::initiate_proxy_connection (Proxy_Handler *proxy_handler) { ACE_Synch_Options synch_options; - + if (this->options ().blocking_semantics_ == ACE_NONBLOCK) synch_options = ACE_Synch_Options::asynch; - else + else synch_options = ACE_Synch_Options::synch; - return this->connector_.initiate_connection (proxy_handler, + return this->connector_.initiate_connection (proxy_handler, synch_options); } @@ -221,12 +221,12 @@ ACE_Event_Channel::complete_proxy_connection (Proxy_Handler *proxy_handler) int socket_queue_size = this->options ().socket_queue_size_; if (socket_queue_size > 0) - if (proxy_handler->peer ().set_option (SOL_SOCKET, + if (proxy_handler->peer ().set_option (SOL_SOCKET, option, &socket_queue_size, sizeof (int)) == -1) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "set_option")); - + proxy_handler->thr_mgr (ACE_Thread_Manager::instance ()); // Our state is now "established." @@ -242,8 +242,8 @@ ACE_Event_Channel::complete_proxy_connection (Proxy_Handler *proxy_handler) ssize_t n = proxy_handler->peer ().send ((const void *) &id, sizeof id); if (n != sizeof id) - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", - n == 0 ? "peer has closed down unexpectedly" : "send"), + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", + n == 0 ? "peer has closed down unexpectedly" : "send"), -1); return 0; } @@ -263,14 +263,14 @@ ACE_Event_Channel::reinitiate_proxy_connection (Proxy_Handler *proxy_handler) if (proxy_handler->state () != Proxy_Handler::DISCONNECTING) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) scheduling reinitiation of Proxy_Handler %d\n", proxy_handler->id ())); - + // Reschedule ourselves to try and connect again. - if (ACE_Reactor::instance ()->schedule_timer + if (ACE_Reactor::instance ()->schedule_timer (proxy_handler, 0, proxy_handler->timeout ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "schedule_timer"), -1); } return 0; @@ -282,7 +282,7 @@ void ACE_Event_Channel::initiate_connector (void) { PROXY_MAP_ITERATOR cmi (this->proxy_map_); - + // Iterate through the Consumer Map connecting all the // Proxy_Handlers. @@ -303,9 +303,9 @@ ACE_Event_Channel::initiate_connector (void) void ACE_Event_Channel::initiate_acceptor (void) { - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (&this->acceptor_, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", + ACE_ERROR ((LM_ERROR, "%p\n", "cannot register acceptor")); } @@ -325,21 +325,21 @@ ACE_Event_Channel::close (u_long) // Tell everyone that the spaceship is here { PROXY_MAP_ITERATOR cmi (this->proxy_map_); - + // Iterate over all the handlers and shut them down. - + for (PROXY_MAP_ENTRY *me; - cmi.next (me) != 0; + cmi.next (me) != 0; cmi.advance ()) { Proxy_Handler *proxy_handler = me->int_id_; - + ACE_DEBUG ((LM_DEBUG, "(%t) closing down connection %d\n", proxy_handler->id ())); - + // Mark Proxy_Handler as DISCONNECTING so we don't try to // reconnect... - proxy_handler->state (Proxy_Handler::DISCONNECTING); + proxy_handler->state (Proxy_Handler::DISCONNECTING); } } @@ -352,9 +352,9 @@ ACE_Event_Channel::close (u_long) // Tell everyone that it is now time to commit suicide { PROXY_MAP_ITERATOR cmi (this->proxy_map_); - + for (PROXY_MAP_ENTRY *me; - cmi.next (me) != 0; + cmi.next (me) != 0; cmi.advance ()) { Proxy_Handler *proxy_handler = me->int_id_; @@ -368,7 +368,7 @@ ACE_Event_Channel::close (u_long) } int -ACE_Event_Channel::find_proxy (ACE_INT32 proxy_id, +ACE_Event_Channel::find_proxy (ACE_INT32 proxy_id, Proxy_Handler *&proxy_handler) { return this->proxy_map_.find (proxy_id, proxy_handler); @@ -382,27 +382,27 @@ ACE_Event_Channel::bind_proxy (Proxy_Handler *proxy_handler) switch (result) { case -1: - ACE_ERROR_RETURN ((LM_ERROR, - "(%t) bind failed for connection %d\n", + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) bind failed for connection %d\n", proxy_handler->id ()), -1); /* NOTREACHED */ case 1: // Oops, found a duplicate! - ACE_ERROR_RETURN ((LM_ERROR, - "(%t) duplicate connection %d, already bound\n", + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) duplicate connection %d, already bound\n", proxy_handler->id ()), -1); /* NOTREACHED */ case 0: // Success. return 0; default: - ACE_ERROR_RETURN ((LM_DEBUG, + ACE_ERROR_RETURN ((LM_DEBUG, "(%t) invalid result %d\n", result), -1); /* NOTREACHED */ } } int -ACE_Event_Channel::subscribe (const Event_Key &event_addr, +ACE_Event_Channel::subscribe (const Event_Key &event_addr, Consumer_Dispatch_Set *cds) { int result = this->efd_.bind (event_addr, cds); @@ -411,12 +411,12 @@ ACE_Event_Channel::subscribe (const Event_Key &event_addr, switch (result) { case -1: - ACE_ERROR_RETURN ((LM_ERROR, - "(%t) bind failed for connection %d\n", + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) bind failed for connection %d\n", event_addr.proxy_id_), -1); /* NOTREACHED */ case 1: // Oops, found a duplicate! - ACE_ERROR_RETURN ((LM_DEBUG, + ACE_ERROR_RETURN ((LM_DEBUG, "(%t) duplicate consumer map entry %d, " "already bound\n", event_addr.proxy_id_), -1); /* NOTREACHED */ @@ -424,7 +424,7 @@ ACE_Event_Channel::subscribe (const Event_Key &event_addr, // Success. return 0; default: - ACE_ERROR_RETURN ((LM_DEBUG, + ACE_ERROR_RETURN ((LM_DEBUG, "(%t) invalid result %d\n", result), -1); /* NOTREACHED */ } @@ -450,16 +450,23 @@ ACE_Event_Channel::open (void *) // thread-safe. Therefore, we create an <ACE_Lock_Adapter> that is // parameterized by <ACE_SYNCH_MUTEX> to prevent race conditions. if (this->options ().threading_strategy_ != ACE_Event_Channel_Options::REACTIVE) - ACE_NEW_RETURN (this->options ().locking_strategy_, - ACE_Lock_Adapter<ACE_SYNCH_MUTEX>, + ACE_NEW_RETURN (this->options ().locking_strategy_, + ACE_Lock_Adapter<ACE_SYNCH_MUTEX>, -1); return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Lock_Adapter<ACE_SYNCH_MUTEX>; template class ACE_Map_Entry<ACE_INT32, Proxy_Handler *>; template class ACE_Map_Iterator<ACE_INT32, Proxy_Handler *, MAP_MUTEX>; template class ACE_Map_Manager<ACE_INT32, Proxy_Handler *, MAP_MUTEX>; template class ACE_Unbounded_Set_Iterator<Proxy_Handler *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Lock_Adapter<ACE_SYNCH_MUTEX> +#pragma instantiate ACE_Map_Entry<ACE_INT32, Proxy_Handler *> +#pragma instantiate ACE_Map_Iterator<ACE_INT32, Proxy_Handler *, MAP_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_INT32, Proxy_Handler *, MAP_MUTEX> +#pragma instantiate ACE_Unbounded_Set_Iterator<Proxy_Handler *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Gateway/Gateway.cpp b/apps/Gateway/Gateway/Gateway.cpp index 699d91d6e85..4b8e8368609 100644 --- a/apps/Gateway/Gateway/Gateway.cpp +++ b/apps/Gateway/Gateway/Gateway.cpp @@ -42,7 +42,7 @@ protected: int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); // Shut down the Gateway when a signal arrives. - int parse_args (int argc, char *argv[]); + int parse_args (int argc, char *argv[]); // Parse gateway configuration arguments obtained from svc.conf // file. @@ -110,7 +110,7 @@ Gateway::parse_args (int argc, char *argv[]) break; case 'C': // Use a different proxy config filename. ACE_OS::strncpy (this->consumer_config_file_, - get_opt.optarg, + get_opt.optarg, sizeof this->consumer_config_file_); break; case 'c': // We are (also?) playing the Connector role. @@ -120,16 +120,16 @@ Gateway::parse_args (int argc, char *argv[]) this->debug_ = 1; break; case 'P': // Use a different consumer config filename. - ACE_OS::strncpy (this->proxy_config_file_, - get_opt.optarg, + ACE_OS::strncpy (this->proxy_config_file_, + get_opt.optarg, sizeof this->proxy_config_file_); break; case 'p': // Use a different acceptor port. - this->event_channel_.options ().acceptor_port_ = + this->event_channel_.options ().acceptor_port_ = ACE_OS::atoi (get_opt.optarg); break; case 'q': // Use a different socket queue size. - this->event_channel_.options ().socket_queue_size_ = + this->event_channel_.options ().socket_queue_size_ = ACE_OS::atoi (get_opt.optarg); break; case 't': // Use a different threading strategy. @@ -139,10 +139,10 @@ Gateway::parse_args (int argc, char *argv[]) flag = ACE_OS::strtok (0, "|")) { if (ACE_OS::strcmp (flag, "OUTPUT_MT") == 0) - ACE_SET_BITS (this->event_channel_.options ().threading_strategy_, + ACE_SET_BITS (this->event_channel_.options ().threading_strategy_, ACE_Event_Channel_Options::OUTPUT_MT); else if (ACE_OS::strcmp (flag, "INPUT_MT") == 0) - ACE_SET_BITS (this->event_channel_.options ().threading_strategy_, + ACE_SET_BITS (this->event_channel_.options ().threading_strategy_, ACE_Event_Channel_Options::INPUT_MT); } @@ -152,7 +152,7 @@ Gateway::parse_args (int argc, char *argv[]) this->event_channel_.options ().verbose_ = 1; break; case 'w': // Time performance for a designated amount of time. - this->event_channel_.options ().performance_window_ = + this->event_channel_.options ().performance_window_ = ACE_OS::atoi (get_opt.optarg); // Use blocking connection semantics so that we get accurate // timings (since all connections start at once). @@ -162,7 +162,7 @@ Gateway::parse_args (int argc, char *argv[]) break; } } - + return 0; } @@ -178,13 +178,13 @@ Gateway::init (int argc, char *argv[]) // Register ourselves to receive SIGINT and SIGQUIT so we can shut // down gracefully via signals. - + #if defined (ACE_WIN32) - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (SIGINT, this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "register_handler"), -1); #else - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (sig_set, this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "register_handler"), -1); #endif @@ -200,12 +200,12 @@ Gateway::init (int argc, char *argv[]) if (this->event_channel_.options ().performance_window_ > 0) { - if (ACE_Reactor::instance ()->schedule_timer - (&this->event_channel_, 0, + if (ACE_Reactor::instance ()->schedule_timer + (&this->event_channel_, 0, this->event_channel_.options ().performance_window_) == -1) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "schedule_timer")); else - ACE_DEBUG ((LM_DEBUG, "starting timer for %d seconds...\n", + ACE_DEBUG ((LM_DEBUG, "starting timer for %d seconds...\n", this->event_channel_.options ().performance_window_)); } @@ -232,14 +232,14 @@ Gateway::fini (void) return this->event_channel_.close (); } -// Returns information on the currently active service. +// Returns information on the currently active service. int Gateway::info (char **strp, size_t length) const { char buf[BUFSIZ]; - ACE_OS::sprintf (buf, "%s\t %s", "Gateway daemon", + ACE_OS::sprintf (buf, "%s\t %s", "Gateway daemon", "# Application-level gateway\n"); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) @@ -260,9 +260,9 @@ Gateway::parse_proxy_config_file (void) int line_number = 0; if (proxy_file.open (this->proxy_config_file_) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%t) %p\n", - this->proxy_config_file_), + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) %p\n", + this->proxy_config_file_), -1); // Read config file one line at a time. @@ -273,21 +273,21 @@ Gateway::parse_proxy_config_file (void) file_empty = 0; if (this->debug_) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) conn id = %d, host = %s, remote port = %d, proxy role = %c, " "max retry timeout = %d, local port = %d, priority = %d\n", - pci.proxy_id_, - pci.host_, - pci.remote_port_, + pci.proxy_id_, + pci.host_, + pci.remote_port_, pci.proxy_role_, - pci.max_retry_timeout_, + pci.max_retry_timeout_, pci.local_port_, pci.priority_)); pci.event_channel_ = &this->event_channel_; // Create the appropriate type of Proxy. - Proxy_Handler *proxy_handler = + Proxy_Handler *proxy_handler = this->proxy_handler_factory_.make_proxy_handler (pci); if (proxy_handler == 0) @@ -298,7 +298,7 @@ Gateway::parse_proxy_config_file (void) } if (file_empty) - ACE_ERROR ((LM_WARNING, + ACE_ERROR ((LM_WARNING, "warning: connection proxy_handler configuration file was empty\n")); return 0; } @@ -325,8 +325,8 @@ Gateway::parse_consumer_config_file (void) { ACE_DEBUG ((LM_DEBUG, "(%t) conn id = %d, supplier id = %d, payload = %d, " "number of consumers = %d\n", - cci.proxy_id_, - cci.supplier_id_, + cci.proxy_id_, + cci.supplier_id_, cci.type_, cci.total_consumers_)); @@ -338,8 +338,8 @@ Gateway::parse_consumer_config_file (void) Consumer_Dispatch_Set *dispatch_set; ACE_NEW_RETURN (dispatch_set, Consumer_Dispatch_Set, -1); - Event_Key event_addr (cci.proxy_id_, - cci.supplier_id_, + Event_Key event_addr (cci.proxy_id_, + cci.supplier_id_, cci.type_); // Add the Consumers to the Dispatch_Set. @@ -349,11 +349,11 @@ Gateway::parse_consumer_config_file (void) // Lookup destination and add to Consumer_Dispatch_Set set // if found. - if (this->event_channel_.find_proxy (cci.consumers_[i], + if (this->event_channel_.find_proxy (cci.consumers_[i], proxy_handler) != -1) dispatch_set->insert (proxy_handler); else - ACE_ERROR ((LM_ERROR, "(%t) not found: destination[%d] = %d\n", + ACE_ERROR ((LM_ERROR, "(%t) not found: destination[%d] = %d\n", i, cci.consumers_[i])); } @@ -361,7 +361,7 @@ Gateway::parse_consumer_config_file (void) } if (file_empty) - ACE_ERROR ((LM_WARNING, + ACE_ERROR ((LM_WARNING, "warning: consumer map configuration file was empty\n")); return 0; } @@ -371,7 +371,11 @@ Gateway::parse_consumer_config_file (void) ACE_SVC_FACTORY_DEFINE (Gateway) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Node<Proxy_Handler *>; template class ACE_Unbounded_Set<Proxy_Handler *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Node<Proxy_Handler *> +#pragma instantiate ACE_Unbounded_Set<Proxy_Handler *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Gateway/Proxy_Handler.cpp b/apps/Gateway/Gateway/Proxy_Handler.cpp index 0543d64dc83..001af047b3e 100644 --- a/apps/Gateway/Gateway/Proxy_Handler.cpp +++ b/apps/Gateway/Gateway/Proxy_Handler.cpp @@ -18,13 +18,13 @@ Proxy_Handler::id (void) // The total number of bytes sent/received on this Proxy. -size_t +size_t Proxy_Handler::total_bytes (void) { return this->total_bytes_; } -void +void Proxy_Handler::total_bytes (size_t bytes) { this->total_bytes_ += bytes; @@ -84,7 +84,7 @@ Proxy_Handler::timeout (void) { int old_timeout = this->timeout_; this->timeout_ *= 2; - + if (this->timeout_ > this->max_timeout_) this->timeout_ = this->max_timeout_; @@ -110,16 +110,16 @@ Proxy_Handler::max_timeout (void) // Restart connection asynchronously when timeout occurs. int -Proxy_Handler::handle_timeout (const ACE_Time_Value &, +Proxy_Handler::handle_timeout (const ACE_Time_Value &, const void *) { - ACE_DEBUG ((LM_DEBUG, - "(%t) attempting to reconnect Proxy_Handler %d with timeout = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) attempting to reconnect Proxy_Handler %d with timeout = %d\n", this->id (), this->timeout_)); // Delegate the re-connection attempt to the Event Channel. this->event_channel_->initiate_proxy_connection (this); - + return 0; } @@ -128,11 +128,11 @@ Proxy_Handler::handle_timeout (const ACE_Time_Value &, int Proxy_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { - ACE_DEBUG ((LM_DEBUG, - "(%t) shutting down %s Proxy_Handler %d on handle %d\n", - this->proxy_role () == 'C' ? "Consumer" : "Supplier", + ACE_DEBUG ((LM_DEBUG, + "(%t) shutting down %s Proxy_Handler %d on handle %d\n", + this->proxy_role () == 'C' ? "Consumer" : "Supplier", this->id (), this->get_handle ())); - + // Restart the connection, if possible. return this->event_channel_->reinitiate_proxy_connection (this); } @@ -152,7 +152,7 @@ int Proxy_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, "(%t) %s Proxy_Handler's handle = %d\n", - this->proxy_role () == 'C' ? "Consumer" : "Supplier", + this->proxy_role () == 'C' ? "Consumer" : "Supplier", this->peer ().get_handle ())); // Call back to the <Event_Channel> to complete our initialization. @@ -164,7 +164,7 @@ Proxy_Handler::open (void *) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "enable"), -1); // Register ourselves to receive input events. - else if (ACE_Reactor::instance ()->register_handler + else if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "register_handler"), -1); else @@ -224,7 +224,7 @@ Proxy_Handler_Factory::make_proxy_handler (const Proxy_Config_Info &pci) { #if defined (ACE_HAS_THREADS) // Create a threaded Supplier_Proxy. - if (ACE_BIT_ENABLED (pci.event_channel_->options ().threading_strategy_, + if (ACE_BIT_ENABLED (pci.event_channel_->options ().threading_strategy_, ACE_Event_Channel_Options::INPUT_MT)) ACE_NEW_RETURN (proxy_handler, Thr_Supplier_Proxy (pci), @@ -241,10 +241,17 @@ Proxy_Handler_Factory::make_proxy_handler (const Proxy_Config_Info &pci) return proxy_handler; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Map_Entry<Event_Key, Consumer_Dispatch_Set *>; template class ACE_Map_Iterator<Event_Key, Consumer_Dispatch_Set *, MAP_MUTEX>; template class ACE_Map_Manager<Event_Key, Consumer_Dispatch_Set *, MAP_MUTEX>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Map_Entry<Event_Key, Consumer_Dispatch_Set *> +#pragma instantiate ACE_Map_Iterator<Event_Key, Consumer_Dispatch_Set *, MAP_MUTEX> +#pragma instantiate ACE_Map_Manager<Event_Key, Consumer_Dispatch_Set *, MAP_MUTEX> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Gateway/Proxy_Handler_Acceptor.cpp b/apps/Gateway/Gateway/Proxy_Handler_Acceptor.cpp index 94b2cb1b55c..487c9e78f9c 100644 --- a/apps/Gateway/Gateway/Proxy_Handler_Acceptor.cpp +++ b/apps/Gateway/Gateway/Proxy_Handler_Acceptor.cpp @@ -8,6 +8,9 @@ Proxy_Handler_Acceptor::Proxy_Handler_Acceptor (ACE_Event_Channel &ec) { } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Proxy_Handler_Factory, ACE_SOCK_ACCEPTOR>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Proxy_Handler_Factory, ACE_SOCK_ACCEPTOR> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Gateway/Proxy_Handler_Connector.cpp b/apps/Gateway/Gateway/Proxy_Handler_Connector.cpp index 55c87e5d276..bb745117d0f 100644 --- a/apps/Gateway/Gateway/Proxy_Handler_Connector.cpp +++ b/apps/Gateway/Gateway/Proxy_Handler_Connector.cpp @@ -14,25 +14,25 @@ Proxy_Handler_Connector::initiate_connection (Proxy_Handler *proxy_handler, { char addr_buf[MAXHOSTNAMELEN]; - // Mark ourselves as idle so that the various iterators + // Mark ourselves as idle so that the various iterators // will ignore us until we are reconnected. proxy_handler->state (Proxy_Handler::IDLE); // We check the remote addr second so that it remains in the addr_buf. if (proxy_handler->local_addr ().addr_to_string (addr_buf, sizeof addr_buf) == -1 || proxy_handler->remote_addr ().addr_to_string (addr_buf, sizeof addr_buf) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "can't obtain peer's address"), -1); // Try to connect to the Peer. - if (this->connect (proxy_handler, proxy_handler->remote_addr (), + if (this->connect (proxy_handler, proxy_handler->remote_addr (), synch_options, proxy_handler->local_addr ()) == -1) { if (errno != EWOULDBLOCK) { proxy_handler->state (Proxy_Handler::FAILED); - ACE_DEBUG ((LM_DEBUG, "(%t) %p on address %s\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %p on address %s\n", "connect", addr_buf)); return -1; @@ -40,24 +40,31 @@ Proxy_Handler_Connector::initiate_connection (Proxy_Handler *proxy_handler, else { proxy_handler->state (Proxy_Handler::CONNECTING); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) in the process of connecting to %s\n", addr_buf)); } } - else + else { proxy_handler->state (Proxy_Handler::ESTABLISHED); - ACE_DEBUG ((LM_DEBUG, "(%t) connected to %s on %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) connected to %s on %d\n", addr_buf, proxy_handler->get_handle ())); } return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<Proxy_Handler, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Tuple<Proxy_Handler>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Proxy_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Proxy_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Proxy_Handler> *>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<Proxy_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Tuple<Proxy_Handler> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Proxy_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Proxy_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Proxy_Handler> *> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/Gateway/Peer/Peer.cpp b/apps/Gateway/Peer/Peer.cpp index 308ca10fe03..1072341b02f 100644 --- a/apps/Gateway/Peer/Peer.cpp +++ b/apps/Gateway/Peer/Peer.cpp @@ -3,7 +3,7 @@ // These classes process Supplier/Consumer events sent from the gateway // (gatewayd) to its various peers (peerd). These classes works as // follows: -// +// // 1. Gateway_Acceptor creates a listener endpoint and waits passively // for gatewayd to connect with it. // @@ -33,7 +33,7 @@ static int verbose = 0; -// Handle Peer events arriving as events. +// Handle Peer events arriving as events. class ACE_Svc_Export Peer_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> { @@ -57,11 +57,11 @@ public: virtual int handle_output (ACE_HANDLE); // Finish sending a event when flow control conditions abate. - virtual int handle_timeout (const ACE_Time_Value &, + virtual int handle_timeout (const ACE_Time_Value &, const void *arg); // Periodically send events via ACE_Reactor timer mechanism. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, + virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); // Perform object termination. @@ -93,7 +93,7 @@ protected: // Pointer-to-member-function for the current action to run in this state. int await_supplier_id (void); - // Action that receives the route id. + // Action that receives the route id. int await_events (void); // Action that receives events. @@ -119,7 +119,7 @@ Peer_Handler::Peer_Handler (void) int Peer_Handler::open (void *a) { - ACE_DEBUG ((LM_DEBUG, "Gateway handler's handle = %d\n", + ACE_DEBUG ((LM_DEBUG, "Gateway handler's handle = %d\n", this->peer ().get_handle ())); // Call down to the base class to activate and register this @@ -128,7 +128,7 @@ Peer_Handler::open (void *a) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); if (this->peer ().enable (ACE_NONBLOCK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enable"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enable"), -1); char *to = ACE_OS::getenv ("TIMEOUT"); int timeout = to == 0 ? 100000 : ACE_OS::atoi (to); @@ -141,7 +141,7 @@ Peer_Handler::open (void *a) // If there are events left in the queue, make sure we enable the // ACE_Reactor appropriately to get them sent out. if (this->msg_queue ()->is_empty () == 0 - && ACE_Reactor::instance ()->schedule_wakeup + && ACE_Reactor::instance ()->schedule_wakeup (this, ACE_Event_Handler::WRITE_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_wakeup"), -1); @@ -159,7 +159,7 @@ Peer_Handler::xmit_stdin (void) { ACE_Message_Block *mb; - ACE_NEW_RETURN (mb, + ACE_NEW_RETURN (mb, ACE_Message_Block (sizeof (Event)), -1); @@ -174,7 +174,7 @@ Peer_Handler::xmit_stdin (void) // Take stdin out of the ACE_Reactor so we stop trying to // send events. - ACE_Reactor::instance ()->remove_handler + ACE_Reactor::instance ()->remove_handler (ACE_STDIN, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK); mb->release (); break; @@ -198,11 +198,11 @@ Peer_Handler::xmit_stdin (void) if (this->put (mb) == -1) { if (errno == EWOULDBLOCK) // The queue has filled up! - ACE_ERROR ((LM_ERROR, "%p\n", + ACE_ERROR ((LM_ERROR, "%p\n", "gateway is flow controlled, so we're dropping events")); else ACE_ERROR ((LM_ERROR, "%p\n", "transmission failure in xmit_stdin")); - + // Caller is responsible for freeing a ACE_Message_Block // if failures occur. mb->release (); @@ -230,15 +230,15 @@ Peer_Handler::nonblk_put (ACE_Message_Block *mb) return -1; else if (errno == EWOULDBLOCK) // Didn't manage to send everything. { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "queueing activated on handle %d to supplier id %d\n", this->get_handle (), this->proxy_id_)); // ACE_Queue in *front* of the list to preserve order. - if (this->msg_queue ()->enqueue_head + if (this->msg_queue ()->enqueue_head (mb, (ACE_Time_Value *) &ACE_Time_Value::zero) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enqueue_head"), -1); - + // Tell ACE_Reactor to call us back when we can send again. if (ACE_Reactor::instance ()->schedule_wakeup (this, ACE_Event_Handler::WRITE_MASK) == -1) @@ -252,15 +252,15 @@ Peer_Handler::nonblk_put (ACE_Message_Block *mb) // Finish sending a event when flow control conditions abate. This // method is automatically called by the ACE_Reactor. -int +int Peer_Handler::handle_output (ACE_HANDLE) { ACE_Message_Block *mb = 0; - + ACE_DEBUG ((LM_DEBUG, "in handle_output\n")); // The list had better not be empty, otherwise there's a bug! - if (this->msg_queue ()->dequeue_head + if (this->msg_queue ()->dequeue_head (mb, (ACE_Time_Value *) &ACE_Time_Value::zero) != -1) { switch (this->nonblk_put (mb)) @@ -274,12 +274,12 @@ Peer_Handler::handle_output (ACE_HANDLE) // Caller is responsible for freeing a ACE_Message_Block if // failures occur. mb->release (); - ACE_ERROR ((LM_ERROR, "%p\n", + ACE_ERROR ((LM_ERROR, "%p\n", "transmission failure in handle_output")); /* FALLTHROUGH */ default: // Sent the whole thing. - + // If we succeed in writing the entire event (or we did not // fail due to EWOULDBLOCK) then check if there are more // events on the Message_Queue. If there aren't, tell the @@ -288,9 +288,9 @@ Peer_Handler::handle_output (ACE_HANDLE) if (this->msg_queue ()->is_empty ()) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "queue now empty on handle %d to supplier id %d\n", - this->get_handle (), + this->get_handle (), this->proxy_id_)); if (ACE_Reactor::instance ()->cancel_wakeup @@ -299,24 +299,24 @@ Peer_Handler::handle_output (ACE_HANDLE) } } } - else + else ACE_ERROR ((LM_ERROR, "%p\n", "dequeue_head")); - return 0; + return 0; } // Send an event to a peer (may block if necessary). -int +int Peer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *) { if (this->msg_queue ()->is_empty ()) // Try to send the event *without* blocking! - return this->nonblk_put (mb); + return this->nonblk_put (mb); else // If we have queued up events due to flow control then just // enqueue and return. - return this->msg_queue ()->enqueue_tail - (mb, (ACE_Time_Value *) &ACE_Time_Value::zero); + return this->msg_queue ()->enqueue_tail + (mb, (ACE_Time_Value *) &ACE_Time_Value::zero); } // Send an Peer event to gatewayd. @@ -324,7 +324,7 @@ Peer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *) int Peer_Handler::send (ACE_Message_Block *mb) { - ssize_t n; + ssize_t n; size_t len = mb->length (); if ((n = this->peer ().send (mb->rd_ptr (), len)) <= 0) @@ -352,31 +352,31 @@ Peer_Handler::send (ACE_Message_Block *mb) int Peer_Handler::recv (ACE_Message_Block *&mb) -{ +{ if (this->msg_frag_ == 0) // No existing fragment... - ACE_NEW_RETURN (this->msg_frag_, - ACE_Message_Block (sizeof (Event)), + ACE_NEW_RETURN (this->msg_frag_, + ACE_Message_Block (sizeof (Event)), -1); Event *event = (Event *) this->msg_frag_->rd_ptr (); ssize_t header_received = 0; const ssize_t HEADER_SIZE = sizeof (Event_Header); - ssize_t header_bytes_left_to_read = + ssize_t header_bytes_left_to_read = HEADER_SIZE - this->msg_frag_->length (); if (header_bytes_left_to_read > 0) { - header_received = this->peer ().recv + header_received = this->peer ().recv (this->msg_frag_->wr_ptr (), header_bytes_left_to_read); if (header_received == -1 /* error */ || header_received == 0 /* EOF */) { - ACE_ERROR ((LM_ERROR, "%p\n", + ACE_ERROR ((LM_ERROR, "%p\n", "Recv error during header read")); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "attempted to read %d bytes\n", header_bytes_left_to_read)); this->msg_frag_ = this->msg_frag_->release (); @@ -389,7 +389,7 @@ Peer_Handler::recv (ACE_Message_Block *&mb) // At this point we may or may not have the ENTIRE header. if (this->msg_frag_->length () < HEADER_SIZE) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "Partial header received: only %d bytes\n", this->msg_frag_->length ())); // Notify the caller that we didn't get an entire event. @@ -405,7 +405,7 @@ Peer_Handler::recv (ACE_Message_Block *&mb) { // This data_ payload is too big! errno = EINVAL; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "Data payload is too big (%d bytes)\n", event->header_.len_)); return -1; @@ -421,10 +421,10 @@ Peer_Handler::recv (ACE_Message_Block *&mb) // subtracting how much we've already read from the // event->header_.len_ we complete the data_bytes_left_to_read... - ssize_t data_bytes_left_to_read = + ssize_t data_bytes_left_to_read = ssize_t (event->header_.len_ - (msg_frag_->wr_ptr () - event->data_)); - ssize_t data_received = + ssize_t data_received = this->peer ().recv (this->msg_frag_->wr_ptr (), data_bytes_left_to_read); // Try to receive the remainder of the event. @@ -432,7 +432,7 @@ Peer_Handler::recv (ACE_Message_Block *&mb) switch (data_received) { case -1: - if (errno == EWOULDBLOCK) + if (errno == EWOULDBLOCK) // This might happen if only the header came through. return -1; else @@ -450,7 +450,7 @@ Peer_Handler::recv (ACE_Message_Block *&mb) { errno = EWOULDBLOCK; // Inform caller that we didn't get the whole event. - return -1; + return -1; } else { @@ -460,7 +460,7 @@ Peer_Handler::recv (ACE_Message_Block *&mb) mb = this->msg_frag_; // Reset the pointer to indicate we've got an entire event. - this->msg_frag_ = 0; + this->msg_frag_ = 0; } ACE_DEBUG ((LM_DEBUG, "(%t) supplier id = %d, cur len = %d, total bytes read = %d\n", @@ -474,7 +474,7 @@ Peer_Handler::recv (ACE_Message_Block *&mb) // Receive various types of input (e.g., Peer event from the // gatewayd, as well as stdio). -int +int Peer_Handler::handle_input (ACE_HANDLE sd) { ACE_DEBUG ((LM_DEBUG, "in handle_input, sd = %d\n", sd)); @@ -491,17 +491,17 @@ Peer_Handler::handle_input (ACE_HANDLE sd) int Peer_Handler::await_supplier_id (void) { - ssize_t n = this->peer ().recv (&this->proxy_id_, + ssize_t n = this->peer ().recv (&this->proxy_id_, sizeof this->proxy_id_); if (n != sizeof this->proxy_id_) { if (n == 0) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "gatewayd has closed down unexpectedly\n"), -1); else - ACE_ERROR_RETURN ((LM_ERROR, - "%p, bytes received on handle %d = %d\n", + ACE_ERROR_RETURN ((LM_ERROR, + "%p, bytes received on handle %d = %d\n", "recv", this->get_handle (), n), -1); } else @@ -554,10 +554,10 @@ Peer_Handler::await_events (void) Event *event = (Event *) mb->rd_ptr (); this->total_bytes_ += mb->length (); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "route id = %d, cur len = %d, total len = %d\n", - event->header_.supplier_id_, - event->header_.len_, + event->header_.supplier_id_, + event->header_.len_, this->total_bytes_)); if (verbose) ACE_DEBUG ((LM_DEBUG, "data_ = %s\n", event->data_)); @@ -591,7 +591,7 @@ Peer_Handler::handle_close (ACE_HANDLE, { if (this->get_handle () != ACE_INVALID_HANDLE) { - ACE_DEBUG ((LM_DEBUG, "shutting down Peer on handle %d\n", + ACE_DEBUG ((LM_DEBUG, "shutting down Peer on handle %d\n", this->get_handle ())); // Explicitly remove ourselves for ACE_STDIN (the ACE_Reactor @@ -599,13 +599,13 @@ Peer_Handler::handle_close (ACE_HANDLE, // ACE_Event_Handler::DONT_CALL instructs the ACE_Reactor *not* // to call this->handle_close(), which would otherwise lead to // recursion!). - ACE_Reactor::instance ()->remove_handler + ACE_Reactor::instance ()->remove_handler (ACE_STDIN, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK); // Deregister this handler with the ACE_Reactor. - if (ACE_Reactor::instance ()->remove_handler + if (ACE_Reactor::instance ()->remove_handler (this, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::ALL_EVENTS_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "handle = %d: %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "handle = %d: %p\n", this->get_handle (), "remove_handler"), -1); // Close down the peer. @@ -619,7 +619,7 @@ Peer_Handler::handle_close (ACE_HANDLE, class ACE_Svc_Export Peer_Acceptor : public ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR> { -public: +public: // = Initialization and termination methods. Peer_Acceptor (void); // Create the Peer. @@ -668,7 +668,7 @@ Peer_Acceptor::make_svc_handler (Peer_Handler *&sh) return 0; } -int +int Peer_Acceptor::handle_signal (int signum, siginfo_t *, ucontext_t *) { ACE_DEBUG ((LM_DEBUG, "signal %S occurred\n", signum)); @@ -725,7 +725,7 @@ Peer_Acceptor::parse_args (int argc, char *argv[]) { switch (c) { - case 'p': + case 'p': this->addr_.set (ACE_OS::atoi (get_opt.optarg)); break; case 'd': @@ -765,11 +765,11 @@ Peer_Acceptor::init (int argc, char *argv[]) // Call down to the Acceptor's open() method. if (this->inherited::open (this->addr_) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); else if (this->acceptor ().get_local_addr (this->addr_) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); else - ACE_DEBUG ((LM_DEBUG, "listening at port %d\n", + ACE_DEBUG ((LM_DEBUG, "listening at port %d\n", this->addr_.get_port_number ())); return 0; } @@ -779,7 +779,11 @@ Peer_Acceptor::init (int argc, char *argv[]) ACE_SVC_FACTORY_DEFINE (Peer_Acceptor) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/JAWS/clients/Blobby/Blob.cpp b/apps/JAWS/clients/Blobby/Blob.cpp index e676e283a99..4f3c5eb6e74 100644 --- a/apps/JAWS/clients/Blobby/Blob.cpp +++ b/apps/JAWS/clients/Blobby/Blob.cpp @@ -7,7 +7,7 @@ ACE_Blob::ACE_Blob (void) { } -ACE_Blob::~ACE_Blob (void) +ACE_Blob::~ACE_Blob (void) { this->close (); } @@ -15,7 +15,7 @@ ACE_Blob::~ACE_Blob (void) // initialize address and filename. No network i/o in open int -ACE_Blob::open (char *filename, char *hostname , u_short port) +ACE_Blob::open (char *filename, char *hostname , u_short port) { filename_ = ACE_OS::strdup(filename); inet_addr_.set (port, hostname); @@ -25,16 +25,16 @@ ACE_Blob::open (char *filename, char *hostname , u_short port) // read from connection length bytes from offset, into Message block -int -ACE_Blob::read (ACE_Message_Block *mb, size_t length, size_t offset) +int +ACE_Blob::read (ACE_Message_Block *mb, size_t length, size_t offset) { // Create a Blob Reader ACE_Blob_Reader blob_reader (mb, length, offset, filename_); ACE_Blob_Handler *brp = &blob_reader; - + // Connect to the server - if (connector_.connect (brp, inet_addr_) == -1) + if (connector_.connect (brp, inet_addr_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob::read():Connector error"), -1); return blob_reader.byte_count (); @@ -43,8 +43,8 @@ ACE_Blob::read (ACE_Message_Block *mb, size_t length, size_t offset) // write to connection length bytes from offset, into Message block -int -ACE_Blob::write (ACE_Message_Block *mb, size_t length, size_t offset) +int +ACE_Blob::write (ACE_Message_Block *mb, size_t length, size_t offset) { // Create a Blob Writer @@ -52,7 +52,7 @@ ACE_Blob::write (ACE_Message_Block *mb, size_t length, size_t offset) ACE_Blob_Handler *bwp = &blob_writer; // Connect to the server - if (connector_.connect (bwp, inet_addr_) == -1) + if (connector_.connect (bwp, inet_addr_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob::write():Connector error"), -1); return blob_writer.byte_count (); @@ -61,10 +61,10 @@ ACE_Blob::write (ACE_Message_Block *mb, size_t length, size_t offset) // close down the blob int -ACE_Blob::close (void) +ACE_Blob::close (void) { - if (filename_) + if (filename_) { ACE_OS::free ((void *) filename_); filename_ = 0; @@ -73,10 +73,17 @@ ACE_Blob::close (void) } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<ACE_Blob_Handler, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Tuple <ACE_Blob_Handler>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple <ACE_Blob_Handler> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple <ACE_Blob_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple <ACE_Blob_Handler> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<ACE_Blob_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Tuple <ACE_Blob_Handler> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple <ACE_Blob_Handler> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple <ACE_Blob_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple <ACE_Blob_Handler> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/JAWS/clients/Blobby/Blob_Handler.cpp b/apps/JAWS/clients/Blobby/Blob_Handler.cpp index 28d98d46cd8..34130d4f4ed 100644 --- a/apps/JAWS/clients/Blobby/Blob_Handler.cpp +++ b/apps/JAWS/clients/Blobby/Blob_Handler.cpp @@ -3,14 +3,14 @@ #include "Blob_Handler.h" // Empty constructor for compliance with new Connector behavior. -ACE_Blob_Handler::ACE_Blob_Handler (void) +ACE_Blob_Handler::ACE_Blob_Handler (void) { } // Always use this constructor -ACE_Blob_Handler::ACE_Blob_Handler (ACE_Message_Block * mb, - size_t length, - size_t offset, +ACE_Blob_Handler::ACE_Blob_Handler (ACE_Message_Block * mb, + size_t length, + size_t offset, char *filename) : mb_ (mb), length_ (length), @@ -20,9 +20,9 @@ ACE_Blob_Handler::ACE_Blob_Handler (ACE_Message_Block * mb, { } -ACE_Blob_Handler::~ACE_Blob_Handler (void) +ACE_Blob_Handler::~ACE_Blob_Handler (void) { - if (filename_) + if (filename_) { ACE_OS::free ((void *) filename_); filename_ = 0; @@ -31,7 +31,7 @@ ACE_Blob_Handler::~ACE_Blob_Handler (void) // Called by Connector after connection is established int -ACE_Blob_Handler::open (void *) +ACE_Blob_Handler::open (void *) { if (this->send_request () != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Handler::open():send_request failed"), -1); @@ -44,7 +44,7 @@ ACE_Blob_Handler::open (void *) // No-op int -ACE_Blob_Handler::close (u_long flags) +ACE_Blob_Handler::close (u_long flags) { ACE_UNUSED_ARG (flags); return 0; @@ -68,16 +68,16 @@ ACE_Blob_Handler::receive_reply (void) // used to retrieve the number of bytes read/written by the // last operation on the Blob int -ACE_Blob_Handler::byte_count (void) +ACE_Blob_Handler::byte_count (void) { return bytecount_; } // Reader ************************************************** -ACE_Blob_Reader::ACE_Blob_Reader (ACE_Message_Block * mb, - size_t length, - size_t offset, +ACE_Blob_Reader::ACE_Blob_Reader (ACE_Message_Block * mb, + size_t length, + size_t offset, char *filename, char *request_prefix, char *request_suffix) : @@ -89,7 +89,7 @@ ACE_Blob_Reader::ACE_Blob_Reader (ACE_Message_Block * mb, // Send the HTTP request int -ACE_Blob_Reader::send_request (void) +ACE_Blob_Reader::send_request (void) { char mesg [MAX_HEADER_SIZE]; @@ -97,20 +97,20 @@ ACE_Blob_Reader::send_request (void) if ( MAX_HEADER_SIZE < (strlen (request_prefix_) + strlen (filename_) + strlen (request_suffix_) + 4)) ACE_ERROR_RETURN((LM_ERROR,"Request too large!"), -1); - // Create a message to send to the server requesting retrieval of the file + // Create a message to send to the server requesting retrieval of the file int len = ACE_OS::sprintf (mesg, "%s %s %s", request_prefix_, filename_, request_suffix_); // Send the message to server if (peer ().send_n (mesg, len) != len) ACE_ERROR_RETURN((LM_ERROR,"Error sending request"), -1); - + return 0; } // Recieve the HTTP Reply -int -ACE_Blob_Reader::receive_reply (void) +int +ACE_Blob_Reader::receive_reply (void) { ssize_t len; char buf [MAX_HEADER_SIZE + 1]; @@ -122,37 +122,37 @@ ACE_Blob_Reader::receive_reply (void) // Receive the first MAX_HEADER_SIZE bytes to be able to strip off the // header. Note that we assume that the header will fit into the // first MAX_HEADER_SIZE bytes of the transmitted data. - if ((len = peer ().recv_n (buf, MAX_HEADER_SIZE)) >= 0) + if ((len = peer ().recv_n (buf, MAX_HEADER_SIZE)) >= 0) { buf[len] = '\0'; // Search for the header termination string "\r\n\r\n", or "\n\n". If // found, move past it to get to the data portion. - if ((buf_ptr = ACE_OS::strstr (buf,"\r\n\r\n")) != NULL) + if ((buf_ptr = ACE_OS::strstr (buf,"\r\n\r\n")) != NULL) buf_ptr += 4; else if ((buf_ptr = ACE_OS::strstr (buf, "\n\n")) != NULL) buf_ptr += 2; - else + else buf_ptr = buf; - + // Determine number of data bytes read. This is equal to the // total butes read minus number of header bytes. bytes_read = (buf + len) - buf_ptr; } else - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Error while reading header"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Error while reading header"), -1); // *************************************************************** // At this point, we have stripped off the header and are ready to // process data. buf_ptr points to the data - // First adjust for offset. There are two cases: + // First adjust for offset. There are two cases: // (1) The first block of data encountered the offset. In this case // we simply increment the buf_ptr by offset. // (2) The first block of data did not encounter the offset. That // is, the offset needs to go past the number of data bytes already read. - if (bytes_read > offset_left) - { + if (bytes_read > offset_left) + { // The first case is true -- that is offset is less than the // data bytes we just read. buf_ptr += offset_left; @@ -166,19 +166,19 @@ ACE_Blob_Reader::receive_reply (void) // our request (for length bytes). If this is the case, then we // don't need to do any extra recvs and can simply return with // the data. - if (data_bytes >= bytes_left) - { + if (data_bytes >= bytes_left) + { // The first block contains enough data to satisfy the // length. So copy the data into the message buffer. - if (mb_->copy (buf_ptr, bytes_left) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", + if (mb_->copy (buf_ptr, bytes_left) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE Blob_Reader::receiveReply():Error copying data into Message_Block"), -1); bytecount_ = length_; return 0; } // Copy over all the data bytes into our message buffer. - if (mb_->copy (buf_ptr, data_bytes) == -1) + if (mb_->copy (buf_ptr, data_bytes) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Error copying data into Message_Block" ), -1); @@ -189,14 +189,14 @@ ACE_Blob_Reader::receive_reply (void) offset_left = 0; } else - { + { // The second case is true -- that is offset is greater than - // the data bytes we just read. + // the data bytes we just read. offset_left -= bytes_read; } - + // If we had any offset left, take care of that. - while (offset_left > 0) + while (offset_left > 0) { // MAX_HEADER_SIZE in which case we should do a receive of // offset bytes into a temporary buffer. Otherwise, we should @@ -207,8 +207,8 @@ ACE_Blob_Reader::receive_reply (void) else len = sizeof buf; if (peer().recv_n (buf, len) != len) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", - "ACE_Blob_Reader::receiveReply():Read error" ), + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", + "ACE_Blob_Reader::receiveReply():Read error" ), -1); offset_left -= len; } @@ -237,9 +237,9 @@ ACE_Blob_Reader::receive_reply (void) // Writer ************************************************** -ACE_Blob_Writer::ACE_Blob_Writer (ACE_Message_Block * mb, - size_t length, - size_t offset, +ACE_Blob_Writer::ACE_Blob_Writer (ACE_Message_Block * mb, + size_t length, + size_t offset, char *filename, char *request_prefix, char *request_suffix) : @@ -249,37 +249,37 @@ ACE_Blob_Writer::ACE_Blob_Writer (ACE_Message_Block * mb, { } -int -ACE_Blob_Writer::send_request (void) +int +ACE_Blob_Writer::send_request (void) { // Check for sanity -- check if we have any data to send. if (offset_+ length_ > mb_->length ()) - ACE_ERROR_RETURN((LM_ERROR, "%p\n", + ACE_ERROR_RETURN((LM_ERROR, "%p\n", "ACE_Blob_Writer::sendRequest():Invalid offset/length"), -1); - + // Determine the length of the header message we will be sending to // the server. Note that we add 32 for safety -- this corresponds to // the number of bytes needed for the length field. - u_short mesglen = - ACE_OS::strlen (request_prefix_) - + ACE_OS::strlen (filename_) + u_short mesglen = + ACE_OS::strlen (request_prefix_) + + ACE_OS::strlen (filename_) + ACE_OS::strlen (request_suffix_) + 32; // safety // Allocate a buffer to hold the header char *mesg; ACE_NEW_RETURN (mesg, char [mesglen], -1); - - // Create the header, store the actual length in mesglen - mesglen = ACE_OS::sprintf (mesg, "%s /%s %s %d\n\n", + + // Create the header, store the actual length in mesglen + mesglen = ACE_OS::sprintf (mesg, "%s /%s %s %d\n\n", request_prefix_, filename_, request_suffix_, length_); - // Send the header followed by the data + // Send the header followed by the data // First send the header if (peer ().send_n (mesg, mesglen) == -1) ACE_ERROR_RETURN((LM_ERROR, "%p\n", "Error sending request"), -1); - + // "Consume" the offset by moving the read pointer of the message // buffer mb_->rd_ptr (offset_); @@ -294,8 +294,8 @@ ACE_Blob_Writer::send_request (void) return 0; } -int -ACE_Blob_Writer::receive_reply (void) +int +ACE_Blob_Writer::receive_reply (void) { // Allocate a buffer big enough to hold the header char buf[MAX_HEADER_SIZE]; @@ -313,17 +313,17 @@ ACE_Blob_Writer::receive_reply (void) // First check if this was a valid header -- HTTP/1.0 char *token = ACE_OS::strtok_r (buf, " \t", &lasts); - if ( (token == NULL) || (ACE_OS::strcasecmp (token, "HTTP/1.0") != 0)) + if ( (token == NULL) || (ACE_OS::strcasecmp (token, "HTTP/1.0") != 0)) ACE_ERROR_RETURN((LM_ERROR, "%p\n", "Did not receive a HTTP/1.0 response"), -1); // Get the return code. int return_code = ACE_OS::atoi (ACE_OS::strtok_r (NULL, " \t", &lasts)); - + // Check if the transaction succeeded. The only success codes are in // the range of 200-299 (HTTP specification). if (return_code >= 200 && return_code < 300) return 0; - else + else { // Something went wrong! // Get the description from the header message of what went wrong. @@ -333,6 +333,9 @@ ACE_Blob_Writer::receive_reply (void) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/JAWS/clients/Caching/http_handler.cpp b/apps/JAWS/clients/Caching/http_handler.cpp index b351aa04106..876d8e3efd8 100644 --- a/apps/JAWS/clients/Caching/http_handler.cpp +++ b/apps/JAWS/clients/Caching/http_handler.cpp @@ -4,13 +4,13 @@ // // = LIBRARY // apps/JAWS/clients/Caching -// +// // = FILENAME // http_handler.cpp // // = AUTHOR // James Hu -// +// // ============================================================================ #include "http_handler.h" @@ -24,7 +24,7 @@ HTTP_Handler::HTTP_Handler (const char * path) { // How long is the request going to be? this->request_[0] = '\0'; - this->request_size_ = + this->request_size_ = ACE_OS::strlen ("GET ") + ACE_OS::strlen (path) + ACE_OS::strlen (" HTTP/1.0\r\nAccept: HTTP/1.0\r\n\r\n"); @@ -83,15 +83,15 @@ HTTP_Handler::svc (void) && ((u_int) count < sizeof (buf))) { buf[count] = '\0'; - if (count < 2) + if (count < 2) continue; done = ACE_OS::strcmp (buf+count-4, "\n\n") == 0; - if (done) + if (done) break; - if (count < 4) + if (count < 4) continue; done = ACE_OS::strcmp (buf+count-4, "\r\n\r\n") == 0; - if (done) + if (done) break; } @@ -114,10 +114,10 @@ HTTP_Handler::svc (void) contentlength = ACE_OS::strstr (buf, "\nContent-length:"); if (!contentlength) - contentlength = + contentlength = ACE_OS::strstr (buf, "\nContent-Length:"); } - + } while (!done); @@ -145,7 +145,7 @@ HTTP_Handler::svc (void) // Perhaps make ACE_Filecache_Handle more savvy, and allow a // constructor which accepts a PEER as a parameter. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "HTTP_Handler, no content-length header!\n")); } @@ -197,18 +197,18 @@ HTTP_Connector::parseurl (const char *url, int status = 0; // hackish, but useful - if (3 != ::sscanf (url, "http://%[^:/]:%hu%s", host, port, path)) + if (3 != ::sscanf (url, "http://%[^:/]:%hu%s", host, port, path)) { - if (2 != ::sscanf (url, "http://%[^:/]:%hu", host, port)) + if (2 != ::sscanf (url, "http://%[^:/]:%hu", host, port)) { - if (2 != ::sscanf (url, "http://%[^:/]%s", host, path)) + if (2 != ::sscanf (url, "http://%[^:/]%s", host, path)) { - if (1 != ::sscanf (url, "http://%[^:/]", host)) + if (1 != ::sscanf (url, "http://%[^:/]", host)) status = -1; else - { + { *port = DEFAULT_SERVER_PORT; - ACE_OS::strcpy (path, "/"); + ACE_OS::strcpy (path, "/"); } } else @@ -222,7 +222,7 @@ HTTP_Connector::parseurl (const char *url, return status; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<HTTP_Handler,ACE_SOCK_CONNECTOR>; template class ACE_Svc_Tuple<HTTP_Handler>; @@ -231,4 +231,14 @@ template class ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH>; template class ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<HTTP_Handler>*>; template class ACE_Map_Manager<ACE_HANDLE,ACE_Svc_Tuple<HTTP_Handler>*,ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Iterator<ACE_HANDLE,ACE_Svc_Tuple<HTTP_Handler>*,ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<HTTP_Handler,ACE_SOCK_CONNECTOR> + +#pragma instantiate ACE_Svc_Tuple<HTTP_Handler> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH> + +#pragma instantiate ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<HTTP_Handler>*> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE,ACE_Svc_Tuple<HTTP_Handler>*,ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE,ACE_Svc_Tuple<HTTP_Handler>*,ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/JAWS/server/HTTP_Server.cpp b/apps/JAWS/server/HTTP_Server.cpp index f249783ce4e..9523bb87d51 100644 --- a/apps/JAWS/server/HTTP_Server.cpp +++ b/apps/JAWS/server/HTTP_Server.cpp @@ -13,16 +13,16 @@ class HTTP_Server_Anchor { public: - enum - { + enum + { POOL = 0, - PER_REQUEST = 1 + PER_REQUEST = 1 }; - enum - { + enum + { SYNCH = 0, - ASYNCH = 2 + ASYNCH = 2 }; }; @@ -44,7 +44,7 @@ HTTP_Server::parse_args (int argc, ACE_Get_Opt get_opt (argc, argv, "p:n:t:i:b:"); while ((c = get_opt ()) != -1) - switch (c) + switch (c) { case 'p': this->port_ = ACE_OS::atoi (get_opt.optarg); @@ -93,7 +93,7 @@ HTTP_Server::parse_args (int argc, default: break; } - + if (this->port_ == 0) this->port_ = 5432; if (this->threads_ == 0) @@ -117,18 +117,18 @@ HTTP_Server::init (int argc, char *argv[]) this->parse_args (argc, argv); - switch (this->strategy_) + switch (this->strategy_) { case 2: - return this->asynch_thread_pool (); + return this->asynch_thread_pool (); - case 1: + case 1: return this->thread_per_request (); - - case 0: - default: - return this->synch_thread_pool (); - } + + case 0: + default: + return this->synch_thread_pool (); + } return 0; } @@ -145,8 +145,8 @@ HTTP_Server::synch_thread_pool (void) if (this->acceptor_.open (ACE_INET_Addr (this->port_), 1, PF_INET, this->backlog_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Acceptor::open"), -1); - - for (int i = 0; i < this->threads_; i++) + + for (int i = 0; i < this->threads_; i++) { Synch_Thread_Pool_Task *t; @@ -154,9 +154,9 @@ HTTP_Server::synch_thread_pool (void) Synch_Thread_Pool_Task (this->acceptor_, this->tm_), -1); - if (t->open () != 0) + if (t->open () != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Pool_Task::open"), -1); - } + } this->tm_.wait (); return 0; @@ -174,7 +174,7 @@ Synch_Thread_Pool_Task::open (void *args) { ACE_UNUSED_ARG (args); - if (this->activate (THR_DETACHED | THR_NEW_LWP) == -1) + if (this->activate (THR_DETACHED | THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Synch_Thread_Pool_Task::open"), -1); @@ -186,7 +186,7 @@ Synch_Thread_Pool_Task::svc (void) { Synch_HTTP_Handler_Factory factory; - for (;;) + for (;;) { ACE_SOCK_Stream stream; @@ -204,7 +204,7 @@ Synch_Thread_Pool_Task::svc (void) ACE_DEBUG ((LM_DEBUG, " (%t) in Synch_Thread_Pool_Task::svc, recycling\n")); } - + // This stinks, because I am afraid that if I remove this line, some // compiler will issue a warning that this routine could exit // without returning a value. But, leaving it in makes the VXWORKS @@ -224,11 +224,11 @@ HTTP_Server::thread_per_request (void) if (this->acceptor_.open (ACE_INET_Addr (this->port_), 1, PF_INET, this->backlog_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Acceptor::open"), -1); - + ACE_SOCK_Stream stream; const ACE_Time_Value wait_time (0,10); - for (;;) + for (;;) { if (this->acceptor_.accept (stream) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Acceptor::accept"), -1); @@ -239,14 +239,14 @@ HTTP_Server::thread_per_request (void) -1); - if (t->open (&grp_id) != 0) + if (t->open (&grp_id) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Per_Request_Task::open"), -1); // Throttling is not allowing too many threads to run away. // Should really use some sort of condition variable here. - if (!this->throttle_) + if (!this->throttle_) continue; // This works because each task has only one thread. @@ -330,7 +330,7 @@ Thread_Per_Request_Task::close (u_long) int HTTP_Server::asynch_thread_pool (void) -{ +{ // This only works on Win32 #if defined (ACE_WIN32) // Create the appropriate acceptor for this concurrency strategy and @@ -343,9 +343,9 @@ HTTP_Server::asynch_thread_pool (void) HTTP_Handler::MAX_REQUEST_SIZE + 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Acceptor::open"), -1); - + // Create the thread pool. - for (int i = 0; i < this->threads_; i++) + for (int i = 0; i < this->threads_; i++) { // Register threads with the proactor and thread manager. Asynch_Thread_Pool_Task *t; @@ -353,11 +353,11 @@ HTTP_Server::asynch_thread_pool (void) Asynch_Thread_Pool_Task (*ACE_Proactor::instance (), this->tm_), -1); - if (t->open () != 0) + if (t->open () != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Pool_Task::open"), -1); // The proactor threads are waiting on the I/O Completion Port. - } + } // Wait for the threads to finish. return this->tm_.wait (); @@ -378,7 +378,7 @@ Asynch_Thread_Pool_Task::Asynch_Thread_Pool_Task (ACE_Proactor &proactor, int Asynch_Thread_Pool_Task::open (void *args) { - if (this->activate () == -1) + if (this->activate () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Asynch_Thread_Pool_Task::open"), -1); @@ -388,7 +388,7 @@ Asynch_Thread_Pool_Task::open (void *args) int Asynch_Thread_Pool_Task::svc (void) { - for (;;) + for (;;) if (this->proactor_.handle_events () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Proactor::handle_events"), -1); @@ -400,13 +400,16 @@ Asynch_Thread_Pool_Task::svc (void) // Define the factory function. ACE_SVC_FACTORY_DEFINE (HTTP_Server) - + // Define the object that describes the service. ACE_STATIC_SVC_DEFINE (HTTP_Server, "HTTP_Server", ACE_SVC_OBJ_T, &ACE_SVC_NAME (HTTP_Server), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class LOCK_SOCK_Acceptor<ACE_SYNCH_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate LOCK_SOCK_Acceptor<ACE_SYNCH_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/apps/JAWS/server/IO.cpp b/apps/JAWS/server/IO.cpp index 6c3fce10433..97ab5abf383 100644 --- a/apps/JAWS/server/IO.cpp +++ b/apps/JAWS/server/IO.cpp @@ -43,7 +43,7 @@ JAWS_Synch_IO::~JAWS_Synch_IO (void) ACE_OS::closesocket (this->handle_); } -void +void JAWS_Synch_IO::read (ACE_Message_Block &mb, int size) { @@ -53,11 +53,11 @@ JAWS_Synch_IO::read (ACE_Message_Block &mb, if (result <= 0) this->handler_->read_error (); - else + else { mb.wr_ptr (result); this->handler_->read_complete (mb); - } + } } void @@ -77,9 +77,9 @@ JAWS_Synch_IO::receive_file (const char *filename, int bytes_to_memcpy = ACE_MIN (entire_length, initial_data_length); ACE_OS::memcpy (handle.address (), initial_data, bytes_to_memcpy); - + int bytes_to_read = entire_length - bytes_to_memcpy; - + int bytes = stream.recv_n ((char *) handle.address () + initial_data_length, bytes_to_read); if (bytes == bytes_to_read) @@ -88,15 +88,15 @@ JAWS_Synch_IO::receive_file (const char *filename, result = -1; } - if (result != ACE_Filecache_Handle::SUCCESS) + if (result != ACE_Filecache_Handle::SUCCESS) this->handler_->receive_file_error (result); } void JAWS_Synch_IO::transmit_file (const char *filename, - const char *header, + const char *header, int header_size, - const char *trailer, + const char *trailer, int trailer_size) { ACE_Filecache_Handle handle (filename); @@ -108,8 +108,8 @@ JAWS_Synch_IO::transmit_file (const char *filename, #if defined (ACE_JAWS_BASELINE) ACE_SOCK_Stream stream; stream.set_handle (this->handle_); - - if ((stream.send_n (header, header_size) == header_size) + + if ((stream.send_n (header, header_size) == header_size) && ((u_long) stream.send_n (handle.address (), handle.size ()) == handle.size ()) && (stream.send_n (trailer, trailer_size) == trailer_size)) @@ -146,33 +146,33 @@ JAWS_Synch_IO::transmit_file (const char *filename, #endif /* ACE_JAWS_BASELINE */ } - if (result != ACE_Filecache_Handle::SUCCESS) + if (result != ACE_Filecache_Handle::SUCCESS) this->handler_->transmit_file_error (result); } -void -JAWS_Synch_IO::send_confirmation_message (const char *buffer, +void +JAWS_Synch_IO::send_confirmation_message (const char *buffer, int length) { this->send_message (buffer, length); this->handler_->confirmation_message_complete (); } -void -JAWS_Synch_IO::send_error_message (const char *buffer, +void +JAWS_Synch_IO::send_error_message (const char *buffer, int length) { this->send_message (buffer, length); this->handler_->error_message_complete (); } -void -JAWS_Synch_IO::send_message (const char *buffer, +void +JAWS_Synch_IO::send_message (const char *buffer, int length) { ACE_SOCK_Stream stream; stream.set_handle (this->handle_); - stream.send_n (buffer, length); + stream.send_n (buffer, length); } // This only works on Win32 @@ -187,13 +187,13 @@ JAWS_Asynch_IO::~JAWS_Asynch_IO (void) ACE_OS::closesocket (this->handle_); } -void +void JAWS_Asynch_IO::read (ACE_Message_Block& mb, int size) { ACE_Asynch_Read_Stream ar; - if (ar.open (*this, this->handle_) == -1 + if (ar.open (*this, this->handle_) == -1 || ar.read (mb, size) == -1) this->handler_->read_error (); } @@ -203,10 +203,10 @@ JAWS_Asynch_IO::read (ACE_Message_Block& mb, void JAWS_Asynch_IO::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) -{ +{ // This callback is for this->receive_file() if (result.act () != 0) - { + { int code = 0; if (result.success () && result.bytes_transferred () != 0) { @@ -215,9 +215,9 @@ JAWS_Asynch_IO::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result else { ACE_Asynch_Read_Stream ar; - if (ar.open (*this, this->handle_) == -1 - || ar.read (result.message_block (), - result.message_block ().size () - result.message_block ().length (), + if (ar.open (*this, this->handle_) == -1 + || ar.read (result.message_block (), + result.message_block ().size () - result.message_block ().length (), result.act ()) == -1) code = -1; else @@ -230,19 +230,19 @@ JAWS_Asynch_IO::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result if (code == ACE_Filecache_Handle::SUCCESS) this->handler_->receive_file_complete (); else - this->handler_->receive_file_error (code); - + this->handler_->receive_file_error (code); + delete &result.message_block (); delete (ACE_Filecache_Handle *) result.act (); } else { // This callback is for this->read() - if (result.success () + if (result.success () && result.bytes_transferred () != 0) this->handler_->read_complete (result.message_block ()); else - this->handler_->read_error (); + this->handler_->read_error (); } } @@ -267,12 +267,12 @@ JAWS_Asynch_IO::receive_file (const char *filename, ACE_OS::memcpy (handle->address (), initial_data, initial_data_length); - + int bytes_to_read = entire_length - initial_data_length; ACE_NEW (mb, ACE_Message_Block ((char *)handle->address () + initial_data_length, bytes_to_read)); - + if (mb == 0) { delete handle; @@ -287,8 +287,8 @@ JAWS_Asynch_IO::receive_file (const char *filename, || ar.read (*mb, mb->size () - mb->length (), handle) == -1) result = -1; } - - if (result != ACE_Filecache_Handle::SUCCESS) + + if (result != ACE_Filecache_Handle::SUCCESS) { this->handler_->receive_file_error (result); delete mb; @@ -298,9 +298,9 @@ JAWS_Asynch_IO::receive_file (const char *filename, void JAWS_Asynch_IO::transmit_file (const char *filename, - const char *header, + const char *header, int header_size, - const char *trailer, + const char *trailer, int trailer_size) { ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer = 0; @@ -318,20 +318,20 @@ JAWS_Asynch_IO::transmit_file (const char *filename, ACE_Asynch_Transmit_File tf; - if (tf.open (*this, this->handle_) == -1 - || tf.transmit_file (handle->handle (), // file handle - header_and_trailer, // header and trailer data + if (tf.open (*this, this->handle_) == -1 + || tf.transmit_file (handle->handle (), // file handle + header_and_trailer, // header and trailer data 0, // bytes_to_write 0, // offset 0, // offset_high 0, // bytes_per_send - 0, // flags + 0, // flags handle // act ) == -1) result = -1; - } - - if (result != ACE_Filecache_Handle::SUCCESS) + } + + if (result != ACE_Filecache_Handle::SUCCESS) { this->handler_->transmit_file_error (result); delete header_and_trailer; @@ -340,36 +340,36 @@ JAWS_Asynch_IO::transmit_file (const char *filename, } -// This method will be called when an asynchronous transmit file completes. -void +// This method will be called when an asynchronous transmit file completes. +void JAWS_Asynch_IO::handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result) { if (result.success ()) this->handler_->transmit_file_complete (); else this->handler_->transmit_file_error (-1); - + delete result.header_and_trailer (); delete (ACE_Filecache_Handle *) result.act (); } -void -JAWS_Asynch_IO::send_confirmation_message (const char *buffer, +void +JAWS_Asynch_IO::send_confirmation_message (const char *buffer, int length) { this->send_message (buffer, length, CONFORMATION); } -void -JAWS_Asynch_IO::send_error_message (const char *buffer, +void +JAWS_Asynch_IO::send_error_message (const char *buffer, int length) { this->send_message (buffer, length, ERROR_MESSAGE); } -void -JAWS_Asynch_IO::send_message (const char *buffer, - int length, +void +JAWS_Asynch_IO::send_message (const char *buffer, + int length, int act) { // James, make sure that you return -1 if new fails (and update callers?). @@ -378,32 +378,35 @@ JAWS_Asynch_IO::send_message (const char *buffer, ACE_NEW (mb, ACE_Message_Block (buffer, length)); ACE_Asynch_Write_Stream aw; - if (aw.open (*this, this->handle_) == -1 + if (aw.open (*this, this->handle_) == -1 || aw.write (*mb, length, (void *) act) == -1) { mb->release (); if (act == CONFORMATION) this->handler_->confirmation_message_complete (); - else + else this->handler_->error_message_complete (); } } void JAWS_Asynch_IO::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) -{ +{ result.message_block ().release (); if (result.act () == (void *) CONFORMATION) this->handler_->confirmation_message_complete (); - else + else this->handler_->error_message_complete (); } #endif /* ACE_WIN32 */ -// #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +// #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // template class ACE_Singleton<JAWS_VFS, ACE_SYNCH_MUTEX>; -// #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +// #pragma instantiate ACE_Singleton<JAWS_VFS, ACE_SYNCH_MUTEX> +// #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp b/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp index 6d144a05216..a54225fa916 100644 --- a/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp +++ b/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp @@ -17,7 +17,7 @@ Peer_Router_Context::send_peers (ACE_Message_Block *mb) // Skip past the header and get the message to send. ACE_Message_Block *data_block = mb->cont (); - + // "Multicast" the data to *all* the registered peers. for (PEER_ENTRY *ss = 0; @@ -25,13 +25,13 @@ Peer_Router_Context::send_peers (ACE_Message_Block *mb) map_iter.advance ()) { if (Options::instance ()->debug ()) - ACE_DEBUG ((LM_DEBUG, - "(%t) sending to peer via handle %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) sending to peer via handle %d\n", ss->ext_id_)); iterations++; // Increment reference count before sending since the // Peer_Handler might be running in its own thread of control. - bytes += ss->int_id_->put (data_block->duplicate ()); + bytes += ss->int_id_->put (data_block->duplicate ()); } mb->release (); @@ -61,7 +61,7 @@ Peer_Router_Context::release (void) } int -Peer_Router_Context::bind_peer (ROUTING_KEY key, +Peer_Router_Context::bind_peer (ROUTING_KEY key, Peer_Handler *peer_handler) { return this->peer_map_.bind (key, peer_handler); @@ -81,17 +81,17 @@ Peer_Router_Context::Peer_Router_Context (u_short port) else { ACE_INET_Addr addr; - + if (this->acceptor().get_local_addr (addr) != -1) - ACE_DEBUG ((LM_DEBUG, - "(%t) initializing %s on port = %d, handle = %d, this = %u\n", - addr.get_port_number () == Options::instance ()->supplier_port () ? + ACE_DEBUG ((LM_DEBUG, + "(%t) initializing %s on port = %d, handle = %d, this = %u\n", + addr.get_port_number () == Options::instance ()->supplier_port () ? "Supplier_Handler" : "Consumer_Handler", addr.get_port_number (), - this->acceptor().get_handle (), + this->acceptor().get_handle (), this)); else - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "%p\n", "get_local_addr")); } } @@ -99,7 +99,7 @@ Peer_Router_Context::Peer_Router_Context (u_short port) Peer_Router_Context::~Peer_Router_Context (void) { // Free up the handle and close down the listening socket. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) closing down Peer_Router_Context\n")); // Close down the Acceptor and take ourselves out of the Reactor. @@ -114,8 +114,8 @@ Peer_Router_Context::~Peer_Router_Context (void) map_iter.advance ()) { if (Options::instance ()->debug ()) - ACE_DEBUG ((LM_DEBUG, - "(%t) closing down peer on handle %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) closing down peer on handle %d\n", ss->ext_id_)); if (ACE_Reactor::instance ()->remove_handler @@ -141,7 +141,7 @@ Peer_Router_Context::peer_router (Peer_Router *pr) int Peer_Router_Context::make_svc_handler (Peer_Handler *&sh) -{ +{ ACE_NEW_RETURN (sh, Peer_Handler (this), -1); return 0; } @@ -175,9 +175,9 @@ Peer_Handler::svc (void) { db = new Message_Block (BUFSIZ); hb = new Message_Block (sizeof (ROUTING_KEY), Message_Block::MB_PROTO, db); - + if ((n = this->peer_.recv (db->rd_ptr (), db->size ())) == -1) - LM_ERROR_RETURN ((LOG_ERROR, "%p", "recv failed"), -1); + LM_ERROR_RETURN ((LOG_ERROR, "%p", "recv failed"), -1); else if (n == 0) // Client has closed down the connection. { if (this->prc_->peer_router ()->unbind_peer (this->get_handle ()) == -1) @@ -186,7 +186,7 @@ Peer_Handler::svc (void) return -1; // We do not need to be deregistered by reactor // as we were not registered at all } - else + else // Transform incoming buffer into a Message and pass // downstream. { @@ -216,7 +216,7 @@ Peer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *tv) int result = 0; - result = this->peer ().send_n (mb->rd_ptr (), + result = this->peer ().send_n (mb->rd_ptr (), mb->length ()); // Release the memory. mb->release (); @@ -241,11 +241,11 @@ Peer_Handler::open (void *) // here. if (this->activate (Options::instance ()->t_flags ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activation of thread failed"), -1); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Peer_Handler::open registering with Reactor for handle_input\n")); #else // Register with the Reactor to receive messages from our Peer. - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); #endif @@ -284,7 +284,7 @@ Peer_Handler::handle_input (ACE_HANDLE h) ssize_t n = this->peer ().recv (db->rd_ptr (), db->size ()); if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); else if (n == 0) // Client has closed down the connection. { if (this->prc_->unbind_peer (this->get_handle ()) == -1) @@ -293,7 +293,7 @@ Peer_Handler::handle_input (ACE_HANDLE h) ACE_DEBUG ((LM_DEBUG, "(%t) shutting down handle %d\n", h)); return -1; // Instruct the ACE_Reactor to deregister us by returning -1. } - else + else { // Transform incoming buffer into a Message. @@ -302,7 +302,7 @@ Peer_Handler::handle_input (ACE_HANDLE h) db->wr_ptr (n); // Second, copy the "address" into the header block. - *(ACE_HANDLE *) hb->rd_ptr () = this->get_handle (); + *(ACE_HANDLE *) hb->rd_ptr () = this->get_handle (); // Third, update the write pointer in the header block. hb->wr_ptr (sizeof (ACE_HANDLE)); @@ -353,10 +353,17 @@ Peer_Router::control (ACE_Message_Block *mb) #endif /* _PEER_ROUTER_C */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Map_Entry<ROUTING_KEY, Peer_Handler *>; template class ACE_Map_Iterator<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Map_Entry<ROUTING_KEY, Peer_Handler *> +#pragma instantiate ACE_Map_Iterator<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/ASX/Event_Server/Transceiver/transceiver.cpp b/examples/ASX/Event_Server/Transceiver/transceiver.cpp index c8904bcbb04..0df775fa37d 100644 --- a/examples/ASX/Event_Server/Transceiver/transceiver.cpp +++ b/examples/ASX/Event_Server/Transceiver/transceiver.cpp @@ -20,7 +20,7 @@ static char role = 'S'; // Handle the command-line arguments. -static void +static void parse_args (int argc, char *argv[]) { ACE_Get_Opt get_opt (argc, argv, "Ch:p:S"); @@ -44,7 +44,7 @@ parse_args (int argc, char *argv[]) role = c; break; default: - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "usage: %n [-p portnum] [-h host_name]\n%a", 1)); /* NOTREACHED */ break; @@ -61,7 +61,7 @@ parse_args (int argc, char *argv[]) class Event_Transceiver : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> // = TITLE // Generate and receives messages from the event server. - // + // // = DESCRIPTION // This class is both a consumer and supplier of events, i.e., // it is a ``transceiver.'' @@ -92,23 +92,23 @@ private: // Writes data from ACE_STDIN to socket. }; -int +int Event_Transceiver::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { - ACE_Reactor::end_event_loop(); + ACE_Reactor::end_event_loop(); return 0; } // Close down via SIGINT or SIGQUIT. -int -Event_Transceiver::handle_signal (int signum, - siginfo_t *, +int +Event_Transceiver::handle_signal (int signum, + siginfo_t *, ucontext_t *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) received signal %S\n", signum)); - + ACE_Reactor::end_event_loop(); return 0; } @@ -116,19 +116,19 @@ Event_Transceiver::handle_signal (int signum, Event_Transceiver::Event_Transceiver (void) { ACE_Sig_Set sig_set; - + sig_set.sig_add (SIGINT); sig_set.sig_add (SIGQUIT); #if !defined (ACE_WIN32) - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (sig_set, this) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); #else - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (SIGINT, this) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); @@ -140,8 +140,8 @@ Event_Transceiver::Event_Transceiver (void) else if (ACE::register_stdin_handler (this, ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) - ACE_ERROR ((LM_ERROR, - "%p\n", + ACE_ERROR ((LM_ERROR, + "%p\n", "register_stdin_handler")); } @@ -152,9 +152,9 @@ Event_Transceiver::open (void *) // socket. if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "register_handler"), + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "register_handler"), -1); return 0; } @@ -206,9 +206,9 @@ Event_Transceiver::receiver (void) return result; } -int -main (int argc, char *argv[]) -{ +int +main (int argc, char *argv[]) +{ ACE_Service_Config daemon (argv[0]); parse_args (argc, argv); @@ -228,11 +228,19 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<Event_Transceiver, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Tuple<Event_Transceiver>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<Event_Transceiver, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Tuple<Event_Transceiver> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp b/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp index ca472f23db4..d797d6668b5 100644 --- a/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp +++ b/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp @@ -11,7 +11,7 @@ int Consumer_Handler::open (void *a) { CONSUMER_FACTORY *af = (CONSUMER_FACTORY *) a; - this->router_task_ = af->router (); + this->router_task_ = af->router (); return this->Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY>::open (a); } @@ -62,7 +62,7 @@ Consumer_Router::close (u_long) // Handle incoming messages in a separate thread.. -int +int Consumer_Router::svc (void) { ACE_Thread_Control tc (this->thr_mgr ()); @@ -85,7 +85,7 @@ Consumer_Router::svc (void) // Send a MESSAGE_BLOCK to the supplier(s).. -int +int Consumer_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) { ACE_ASSERT (this->is_reader ()); @@ -104,21 +104,21 @@ Consumer_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) // Return information about the Client_Router ACE_Module.. -int +int Consumer_Router::info (char **strp, size_t length) const { char buf[BUFSIZ]; ACE_UPIPE_Addr addr; const char *mod_name = this->name (); ACE_UPIPE_Acceptor &sa = (ACE_UPIPE_Acceptor &) *this->acceptor_; - + if (sa.get_local_addr (addr) == -1) return -1; - + ACE_OS::sprintf (buf, "%s\t /%s %s", mod_name, "upipe", "# consumer router\n"); - + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) return -1; else @@ -126,7 +126,7 @@ Consumer_Router::info (char **strp, size_t length) const return ACE_OS::strlen (mod_name); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Consumer_Handler, ACE_UPIPE_ACCEPTOR>; template class Acceptor_Factory<Consumer_Handler, CONSUMER_KEY>; template class Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY>; @@ -134,5 +134,14 @@ template class Peer_Router<Consumer_Handler, CONSUMER_KEY>; template class ACE_Map_Entry<CONSUMER_KEY, Consumer_Handler *>; template class ACE_Map_Iterator<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex>; template class ACE_Map_Manager<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Consumer_Handler, ACE_UPIPE_ACCEPTOR> +#pragma instantiate Acceptor_Factory<Consumer_Handler, CONSUMER_KEY> +#pragma instantiate Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY> +#pragma instantiate Peer_Router<Consumer_Handler, CONSUMER_KEY> +#pragma instantiate ACE_Map_Entry<CONSUMER_KEY, Consumer_Handler *> +#pragma instantiate ACE_Map_Iterator<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex> +#pragma instantiate ACE_Map_Manager<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp b/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp index 9f2de1c41e6..e0956ed6215 100644 --- a/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp +++ b/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp @@ -11,7 +11,7 @@ int Supplier_Handler::open (void *a) { SUPPLIER_FACTORY *af = (SUPPLIER_FACTORY *) a; - this->router_task_ = af->router (); + this->router_task_ = af->router (); return this->Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY>::open (a); } @@ -29,7 +29,7 @@ Supplier_Router::Supplier_Router (ACE_Thread_Manager *tm) // Handle incoming messages in a separate thread.. -int +int Supplier_Router::svc (void) { ACE_ASSERT (this->is_writer ()); @@ -85,7 +85,7 @@ Supplier_Router::close (u_long) // Send a MESSAGE_BLOCK to the supplier(s).. -int +int Supplier_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) { ACE_ASSERT (this->is_writer ()); @@ -104,7 +104,7 @@ Supplier_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) // Return information about the Supplier_Router ACE_Module.. -int +int Supplier_Router::info (char **strp, size_t length) const { char buf[BUFSIZ]; @@ -114,11 +114,11 @@ Supplier_Router::info (char **strp, size_t length) const if (sa.get_local_addr (addr) == -1) return -1; - + ACE_OS::sprintf (buf, "%s\t %s/ %s", mod_name, "upipe", "# supplier router\n"); - + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) return -1; else @@ -126,7 +126,7 @@ Supplier_Router::info (char **strp, size_t length) const return ACE_OS::strlen (mod_name); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class Acceptor_Factory<Supplier_Handler, SUPPLIER_KEY>; template class ACE_Acceptor<Supplier_Handler, ACE_UPIPE_ACCEPTOR>; template class ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_MT_SYNCH>; @@ -139,6 +139,20 @@ template class ACE_Read_Guard<ACE_RW_Mutex>; template class ACE_Write_Guard<ACE_RW_Mutex>; template class ACE_Guard<ACE_RW_Mutex>; template class ACE_TSS<ACE_Dynamic>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate Acceptor_Factory<Supplier_Handler, SUPPLIER_KEY> +#pragma instantiate ACE_Acceptor<Supplier_Handler, ACE_UPIPE_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_MT_SYNCH> +#pragma instantiate Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY> +#pragma instantiate Peer_Router<Supplier_Handler, SUPPLIER_KEY> +#pragma instantiate ACE_Map_Entry<SUPPLIER_KEY, Supplier_Handler *> +#pragma instantiate ACE_Map_Iterator<SUPPLIER_KEY, Supplier_Handler *, ACE_RW_Mutex> +#pragma instantiate ACE_Map_Manager<SUPPLIER_KEY, Supplier_Handler *, ACE_RW_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_TSS<ACE_Dynamic> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ diff --git a/examples/Connection/blocking/SPIPE-acceptor.cpp b/examples/Connection/blocking/SPIPE-acceptor.cpp index a1548f39205..c103dbb82a0 100644 --- a/examples/Connection/blocking/SPIPE-acceptor.cpp +++ b/examples/Connection/blocking/SPIPE-acceptor.cpp @@ -20,17 +20,17 @@ Svc_Handler::~Svc_Handler (void) { } -int +int Svc_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, "client connected on handle %d\n", this->peer ().get_handle ())); if (this->ar_.open (*this, this->peer ().get_handle ()) == -1) - return -1; + return -1; return this->ar_.read (this->mb_, this->mb_.size ()); } -void +void Svc_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { if (result.success () && result.bytes_transferred () > 0) @@ -39,7 +39,7 @@ Svc_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) // Print out the message received from the server. ACE_DEBUG ((LM_DEBUG, "(%t) message size %d.\n", result.message_block ().length ())); ACE_DEBUG ((LM_DEBUG, "%s", result.message_block ().rd_ptr ())); - + this->ar_.read (this->mb_, this->mb_.size ()); } else @@ -57,7 +57,7 @@ IPC_Server::~IPC_Server (void) { } -int +int IPC_Server::init (int argc, char *argv[]) { if (this->parse_args (argc, argv) == -1) @@ -77,7 +77,7 @@ IPC_Server::init (int argc, char *argv[]) return 0; } -int +int IPC_Server::fini (void) { return 0; @@ -95,13 +95,13 @@ IPC_Server::parse_args (int argc, char *argv[]) switch (c) { case 'r': - ACE_OS::strncpy (rendezvous_, + ACE_OS::strncpy (rendezvous_, ACE_WIDE_STRING (get_opt.optarg), sizeof rendezvous_ / sizeof TCHAR); break; case 't': n_threads_ = ACE_OS::atoi (get_opt.optarg); - ACE_DEBUG ((LM_DEBUG, "%s == %d.\n", + ACE_DEBUG ((LM_DEBUG, "%s == %d.\n", get_opt.optarg, n_threads_)); ACE_Proactor::instance(2*n_threads_); @@ -130,14 +130,14 @@ run_reactor_event_loop (void *) return 0; } -int +int IPC_Server::svc (void) { // Performs the iterative server activities. while (ACE_Reactor::event_loop_done() == 0) { Svc_Handler sh; - + // Create a new SH endpoint, which performs all processing in // its open() method (note no automatic restart if errno == // EINTR). @@ -163,7 +163,7 @@ IPC_Server::svc (void) ACE_DEBUG ((LM_DEBUG, "(%t) main thread exiting.\n")); } } - + /* NOTREACHED */ return 0; } @@ -171,7 +171,11 @@ IPC_Server::svc (void) #endif /* SPIPE_ACCEPTOR_C */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Concurrency_Strategy<Svc_Handler>; template class ACE_Oneshot_Acceptor<Svc_Handler, ACE_SPIPE_ACCEPTOR>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Concurrency_Strategy<Svc_Handler> +#pragma instantiate ACE_Oneshot_Acceptor<Svc_Handler, ACE_SPIPE_ACCEPTOR> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/blocking/SPIPE-connector.cpp b/examples/Connection/blocking/SPIPE-connector.cpp index 60ef04275ba..8c05d458a39 100644 --- a/examples/Connection/blocking/SPIPE-connector.cpp +++ b/examples/Connection/blocking/SPIPE-connector.cpp @@ -18,7 +18,7 @@ Peer_Handler::~Peer_Handler () { } -int +int Peer_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, "activating %d\n", this->get_handle ())); @@ -31,12 +31,12 @@ Peer_Handler::open (void *) ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); - else + else return 0; } else // If iterations_ has been set, send iterations_ buffers. { - char *buffer = + char *buffer = "Oh give me a home\n" "Where the buffalo roam,\n" "And the deer and the antelope play.\n" @@ -44,18 +44,18 @@ Peer_Handler::open (void *) "A discouraging word,\n" "And the skies are not cloudy all day.\n"; int length = ACE_OS::strlen (buffer); - + while (iterations_-- > 0 && this->peer ().send_n (buffer, length) == length) continue; - + this->peer ().close (); ACE_Reactor::end_event_loop(); return 0; } } -int +int Peer_Handler::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; @@ -67,7 +67,7 @@ Peer_Handler::handle_input (ACE_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write failed"), -1); else if (n == 0) /* Explicitly close the connection. */ { - if (this->peer ().close () == -1) + if (this->peer ().close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); return -1; } @@ -76,7 +76,7 @@ Peer_Handler::handle_input (ACE_HANDLE) return 0; } -int +int Peer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { @@ -84,7 +84,7 @@ Peer_Handler::handle_close (ACE_HANDLE, return 0; } -ACE_HANDLE +ACE_HANDLE Peer_Handler::get_handle (void) const { return this->peer ().get_handle (); @@ -109,7 +109,7 @@ IPC_Client::~IPC_Client (void) // Dynamic linking hooks. -int +int IPC_Client::init (int argc, char *argv[]) { if (this->parse_args (argc, argv) == -1) @@ -122,7 +122,7 @@ IPC_Client::init (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "Opening %s\n", ACE_MULTIBYTE_STRING (rendezvous_))); Peer_Handler *ph; - + ACE_NEW_RETURN (ph, Peer_Handler (iterations_), -1); // Connect to the peer, reusing the local addr if necessary. @@ -138,20 +138,20 @@ IPC_Client::init (int argc, char *argv[]) return 0; } -int +int IPC_Client::fini (void) { return 0; } -int +int IPC_Client::svc (void) { ACE_Reactor::run_event_loop (); return 0; } -int +int IPC_Client::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { return 0; @@ -169,7 +169,7 @@ IPC_Client::parse_args (int argc, char *argv[]) switch (c) { case 'r': - ACE_OS::strncpy (rendezvous_, + ACE_OS::strncpy (rendezvous_, ACE_WIDE_STRING (get_opt.optarg), sizeof rendezvous_ / sizeof TCHAR); break; @@ -192,10 +192,17 @@ IPC_Client::parse_args (int argc, char *argv[]) #endif /* SPIPE_CONNECTOR */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<Peer_Handler, ACE_SPIPE_CONNECTOR>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Tuple<Peer_Handler>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<Peer_Handler, ACE_SPIPE_CONNECTOR> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Tuple<Peer_Handler> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/misc/Connection_Handler.cpp b/examples/Connection/misc/Connection_Handler.cpp index 79141d9e1c2..e7934dbb375 100644 --- a/examples/Connection/misc/Connection_Handler.cpp +++ b/examples/Connection/misc/Connection_Handler.cpp @@ -1,7 +1,7 @@ // $Id$ // ============================================================================ -// +// // = FILENAME // Connection_Handler.cpp // @@ -9,11 +9,11 @@ // This test illustrates how to use the Acceptor pattern to // create multiple threads, each running its own Reactor. You // can connect to this via telnet and keep typing until you enter -// '^D'. +// '^D'. // // = AUTHOR // Doug Schmidt -// +// // ============================================================================ #include "ace/Acceptor.h" @@ -34,14 +34,14 @@ public: // Run the <Connection_Handler>'s main event loop. protected: - virtual int handle_close (ACE_HANDLE, + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); // Signal the Active Object to stop when called. virtual int handle_input (ACE_HANDLE); // Handle input from the client. - virtual int handle_timeout (const ACE_Time_Value &tv, + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); // Handle timeouts. @@ -54,7 +54,7 @@ protected: // Keeps track of whether we're done. }; -int +int Connection_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) in open()\n")); @@ -73,7 +73,7 @@ Connection_Handler::close (u_long) return 0; } -int +int Connection_Handler::svc (void) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) in svc()\n")); @@ -93,14 +93,14 @@ Connection_Handler::svc (void) // Register ourselves to handle input in this thread without // blocking. - if (this->reactor ()->register_handler + if (this->reactor ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "can' (%P|%t) t register with reactor\n"), -1); // Schedule a timer. - else if (this->reactor ()->schedule_timer (this, - (const void *) this, - ACE_Time_Value (2), + else if (this->reactor ()->schedule_timer (this, + (const void *) this, + ACE_Time_Value (2), ACE_Time_Value (2)) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1); else @@ -118,7 +118,7 @@ Connection_Handler::svc (void) ACE_Reactor::instance ()->cancel_timer (this); // Remove ourselves from the Reactor. - this->reactor ()->remove_handler + this->reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); // Zero-out the Reactor field so it isn't accessed later on. @@ -126,10 +126,10 @@ Connection_Handler::svc (void) ACE_DEBUG ((LM_DEBUG, " (%P|%t) exiting svc\n")); return 0; -} +} -int -Connection_Handler::handle_close (ACE_HANDLE, +int +Connection_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, " (%P|%t) in handle_close \n")); @@ -139,7 +139,7 @@ Connection_Handler::handle_close (ACE_HANDLE, return 0; } -int +int Connection_Handler::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; @@ -151,11 +151,11 @@ Connection_Handler::handle_input (ACE_HANDLE) case -1: ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) %p bad read\n", "client logger"), -1); case 0: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) closing log daemon (fd = %d)\n", this->get_handle ()), -1); default: if (((int) buf[0]) == EOF) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) closing log daemon (fd = %d)\n", this->get_handle ()), -1); else ACE_DEBUG ((LM_DEBUG, " (%P|%t) from client: %s", buf)); @@ -164,7 +164,7 @@ Connection_Handler::handle_input (ACE_HANDLE) return 0; } -int +int Connection_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) @@ -174,8 +174,8 @@ Connection_Handler::handle_signal (int signum, return 0; } -int -Connection_Handler::handle_timeout (const ACE_Time_Value &tv, +int +Connection_Handler::handle_timeout (const ACE_Time_Value &tv, const void *arg) { ACE_UNUSED_ARG (tv); @@ -187,10 +187,10 @@ Connection_Handler::handle_timeout (const ACE_Time_Value &tv, // Define an Acceptor for the <Connection_Handler>. -typedef ACE_Acceptor <Connection_Handler, ACE_SOCK_ACCEPTOR> +typedef ACE_Acceptor <Connection_Handler, ACE_SOCK_ACCEPTOR> Connection_Acceptor; -int +int main (int argc, char *argv[]) { ACE_Service_Config daemon (argv[0]); @@ -226,7 +226,11 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Connection_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Connection_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/misc/test_upipe.cpp b/examples/Connection/misc/test_upipe.cpp index fc782d1ed3d..73fb2a06103 100644 --- a/examples/Connection/misc/test_upipe.cpp +++ b/examples/Connection/misc/test_upipe.cpp @@ -51,7 +51,7 @@ class Server : public ACE_Strategy_Acceptor <Server_Service, ACE_UPIPE_ACCEPTOR> public: Server (ACE_Thread_Manager *thr_mgr, ACE_Reactor *reactor) - : reactor_ (reactor), + : reactor_ (reactor), thr_mgr_ (thr_mgr) { ACE_TRACE ("Server::Server"); @@ -63,7 +63,7 @@ public: const char *l_addr = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; ACE_UPIPE_Addr local_addr (l_addr); - + if (this->thr_strategy_.open (this->thr_mgr_, THR_DETACHED | THR_NEW_LWP) == -1) return -1; else if (this->open (local_addr, this->reactor_, @@ -78,10 +78,10 @@ public: private: ACE_Reactor *reactor_; // Our instance of the reactor. - + ACE_Thread_Manager *thr_mgr_; // Our instance of a thread manager. - + ACE_Thread_Strategy<Server_Service> thr_strategy_; // Our concurrency strategy. }; @@ -139,7 +139,7 @@ public: ACE_UPIPE_Addr remote_addr (r_addr); Client_Service *cs; - + ACE_NEW_RETURN (cs, Client_Service (this->thr_mgr_), -1); return this->connect (cs, remote_addr); @@ -150,9 +150,9 @@ private: }; //---------------------------------------- - -int main (int argc, char *argv[]) -{ + +int main (int argc, char *argv[]) +{ ACE_Service_Config svc_conf; ACE_Thread_Manager thr_mgr; @@ -169,9 +169,9 @@ int main (int argc, char *argv[]) // Wait for threads to exit. thr_mgr.wait (); return 0; -} +} -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Accept_Strategy<Server_Service, ACE_UPIPE_ACCEPTOR>; template class ACE_Acceptor<Server_Service, ACE_UPIPE_ACCEPTOR>; template class ACE_Concurrency_Strategy<Server_Service>; @@ -185,7 +185,22 @@ template class ACE_Strategy_Acceptor<Server_Service, ACE_UPIPE_ACCEPTOR>; template class ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Tuple<Client_Service>; template class ACE_Thread_Strategy<Server_Service>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Accept_Strategy<Server_Service, ACE_UPIPE_ACCEPTOR> +#pragma instantiate ACE_Acceptor<Server_Service, ACE_UPIPE_ACCEPTOR> +#pragma instantiate ACE_Concurrency_Strategy<Server_Service> +#pragma instantiate ACE_Connector<Client_Service, ACE_UPIPE_CONNECTOR> +#pragma instantiate ACE_Creation_Strategy<Server_Service> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Client_Service> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Client_Service> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Client_Service> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Scheduling_Strategy<Server_Service> +#pragma instantiate ACE_Strategy_Acceptor<Server_Service, ACE_UPIPE_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Tuple<Client_Service> +#pragma instantiate ACE_Thread_Strategy<Server_Service> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else int diff --git a/examples/Connection/non_blocking/test_lsock_acceptor.cpp b/examples/Connection/non_blocking/test_lsock_acceptor.cpp index 7b501ad42dd..90b2d43e92f 100644 --- a/examples/Connection/non_blocking/test_lsock_acceptor.cpp +++ b/examples/Connection/non_blocking/test_lsock_acceptor.cpp @@ -9,14 +9,14 @@ typedef Svc_Handler<ACE_LSOCK_STREAM> SVC_HANDLER; typedef IPC_Server<SVC_HANDLER, ACE_LSOCK_ACCEPTOR> IPC_SERVER; -int +int main (int argc, char *argv[]) -{ +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; - + if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); @@ -24,10 +24,17 @@ main (int argc, char *argv[]) } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Concurrency_Strategy<SVC_HANDLER>; template class ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_LSOCK_ACCEPTOR>; template class ACE_Svc_Handler<ACE_LSOCK_STREAM, ACE_NULL_SYNCH>; template class IPC_Server<SVC_HANDLER, ACE_LSOCK_ACCEPTOR>; template class Svc_Handler<ACE_LSOCK_STREAM>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Concurrency_Strategy<SVC_HANDLER> +#pragma instantiate ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_LSOCK_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_LSOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate IPC_Server<SVC_HANDLER, ACE_LSOCK_ACCEPTOR> +#pragma instantiate Svc_Handler<ACE_LSOCK_STREAM> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/non_blocking/test_lsock_connector.cpp b/examples/Connection/non_blocking/test_lsock_connector.cpp index 7924a2a9a10..1271de5961d 100644 --- a/examples/Connection/non_blocking/test_lsock_connector.cpp +++ b/examples/Connection/non_blocking/test_lsock_connector.cpp @@ -8,10 +8,10 @@ typedef Peer_Handler<ACE_LSOCK_STREAM> PEER_HANDLER; typedef IPC_Client<PEER_HANDLER, ACE_LSOCK_CONNECTOR> IPC_CLIENT; // ACE_LSOCK Client. - -int -main (int argc, char *argv[]) -{ + +int +main (int argc, char *argv[]) +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); @@ -19,11 +19,11 @@ main (int argc, char *argv[]) if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); - + return peer_connector.svc (); -} +} -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<PEER_HANDLER, ACE_LSOCK_CONNECTOR>; template class ACE_Svc_Handler<ACE_LSOCK_STREAM, ACE_SYNCH>; template class ACE_Svc_Tuple<PEER_HANDLER>; @@ -32,4 +32,14 @@ template class Peer_Handler<ACE_LSOCK_STREAM>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<PEER_HANDLER, ACE_LSOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_LSOCK_STREAM, ACE_SYNCH> +#pragma instantiate ACE_Svc_Tuple<PEER_HANDLER> +#pragma instantiate IPC_Client<PEER_HANDLER, ACE_LSOCK_CONNECTOR> +#pragma instantiate Peer_Handler<ACE_LSOCK_STREAM> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/non_blocking/test_sock_acceptor.cpp b/examples/Connection/non_blocking/test_sock_acceptor.cpp index 25cc996fcc5..43dd9ec5194 100644 --- a/examples/Connection/non_blocking/test_sock_acceptor.cpp +++ b/examples/Connection/non_blocking/test_sock_acceptor.cpp @@ -9,14 +9,14 @@ typedef Svc_Handler<ACE_SOCK_STREAM> SVC_HANDLER; typedef IPC_Server<SVC_HANDLER, ACE_SOCK_ACCEPTOR> IPC_SERVER; -int +int main (int argc, char *argv[]) -{ +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; - + if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); @@ -24,10 +24,17 @@ main (int argc, char *argv[]) } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Concurrency_Strategy<SVC_HANDLER>; template class ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_SOCK_ACCEPTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class IPC_Server<SVC_HANDLER, ACE_SOCK_ACCEPTOR>; template class Svc_Handler<ACE_SOCK_STREAM>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Concurrency_Strategy<SVC_HANDLER> +#pragma instantiate ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate IPC_Server<SVC_HANDLER, ACE_SOCK_ACCEPTOR> +#pragma instantiate Svc_Handler<ACE_SOCK_STREAM> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/non_blocking/test_sock_connector.cpp b/examples/Connection/non_blocking/test_sock_connector.cpp index 1d1f9c024be..1552501b3f2 100644 --- a/examples/Connection/non_blocking/test_sock_connector.cpp +++ b/examples/Connection/non_blocking/test_sock_connector.cpp @@ -8,10 +8,10 @@ typedef Peer_Handler<ACE_SOCK_STREAM> PEER_HANDLER; typedef IPC_Client<PEER_HANDLER, ACE_SOCK_CONNECTOR> IPC_CLIENT; // ACE_SOCK Client. - -int -main (int argc, char *argv[]) -{ + +int +main (int argc, char *argv[]) +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); @@ -19,11 +19,11 @@ main (int argc, char *argv[]) if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); - + return peer_connector.svc (); -} +} -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<PEER_HANDLER, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>; template class ACE_Svc_Tuple<PEER_HANDLER>; @@ -32,4 +32,14 @@ template class Peer_Handler<ACE_SOCK_STREAM>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<PEER_HANDLER, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH> +#pragma instantiate ACE_Svc_Tuple<PEER_HANDLER> +#pragma instantiate IPC_Client<PEER_HANDLER, ACE_SOCK_CONNECTOR> +#pragma instantiate Peer_Handler<ACE_SOCK_STREAM> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/non_blocking/test_spipe_acceptor.cpp b/examples/Connection/non_blocking/test_spipe_acceptor.cpp index 76374f208f6..c6d98bbd912 100644 --- a/examples/Connection/non_blocking/test_spipe_acceptor.cpp +++ b/examples/Connection/non_blocking/test_spipe_acceptor.cpp @@ -9,27 +9,34 @@ typedef Svc_Handler<ACE_SPIPE_STREAM> SVC_HANDLER; typedef IPC_Server<SVC_HANDLER, ACE_SPIPE_ACCEPTOR> IPC_SERVER; -int +int main (int argc, char *argv[]) -{ +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; - + if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); return peer_acceptor.svc (); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Concurrency_Strategy<SVC_HANDLER>; template class ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_SPIPE_ACCEPTOR>; template class ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH>; template class IPC_Server<SVC_HANDLER, ACE_SPIPE_ACCEPTOR>; template class Svc_Handler<ACE_SPIPE_STREAM>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Concurrency_Strategy<SVC_HANDLER> +#pragma instantiate ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_SPIPE_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH> +#pragma instantiate IPC_Server<SVC_HANDLER, ACE_SPIPE_ACCEPTOR> +#pragma instantiate Svc_Handler<ACE_SPIPE_STREAM> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else int diff --git a/examples/Connection/non_blocking/test_spipe_connector.cpp b/examples/Connection/non_blocking/test_spipe_connector.cpp index b56011e234a..d8b367b1347 100644 --- a/examples/Connection/non_blocking/test_spipe_connector.cpp +++ b/examples/Connection/non_blocking/test_spipe_connector.cpp @@ -8,10 +8,10 @@ #if !defined (ACE_WIN32) typedef Peer_Handler<ACE_SPIPE_STREAM> PEER_HANDLER; typedef IPC_Client<PEER_HANDLER, ACE_SPIPE_CONNECTOR> IPC_CLIENT; - -int -main (int argc, char *argv[]) -{ + +int +main (int argc, char *argv[]) +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); @@ -19,11 +19,11 @@ main (int argc, char *argv[]) if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); - + return peer_connector.svc (); -} +} -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<PEER_HANDLER, ACE_SPIPE_CONNECTOR>; template class ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_SYNCH>; template class ACE_Svc_Tuple<PEER_HANDLER>; @@ -32,7 +32,17 @@ template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_S template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX>; template class IPC_Client<PEER_HANDLER, ACE_SPIPE_CONNECTOR>; template class Peer_Handler<ACE_SPIPE_STREAM>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<PEER_HANDLER, ACE_SPIPE_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_SYNCH> +#pragma instantiate ACE_Svc_Tuple<PEER_HANDLER> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate IPC_Client<PEER_HANDLER, ACE_SPIPE_CONNECTOR> +#pragma instantiate Peer_Handler<ACE_SPIPE_STREAM> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else int diff --git a/examples/Connection/non_blocking/test_tli_acceptor.cpp b/examples/Connection/non_blocking/test_tli_acceptor.cpp index fb7e373dddb..3b1008f4f3c 100644 --- a/examples/Connection/non_blocking/test_tli_acceptor.cpp +++ b/examples/Connection/non_blocking/test_tli_acceptor.cpp @@ -10,27 +10,34 @@ typedef Svc_Handler<ACE_TLI_STREAM> SVC_HANDLER; typedef IPC_Server<SVC_HANDLER, ACE_TLI_ACCEPTOR> IPC_SERVER; -int +int main (int argc, char *argv[]) -{ +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; - + if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); return peer_acceptor.svc (); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Concurrency_Strategy<SVC_HANDLER>; template class ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_TLI_ACCEPTOR>; template class ACE_Svc_Handler<ACE_TLI_STREAM, ACE_NULL_SYNCH>; template class IPC_Server<SVC_HANDLER, ACE_TLI_ACCEPTOR>; template class Svc_Handler<ACE_TLI_STREAM>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Concurrency_Strategy<SVC_HANDLER> +#pragma instantiate ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_TLI_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_TLI_STREAM, ACE_NULL_SYNCH> +#pragma instantiate IPC_Server<SVC_HANDLER, ACE_TLI_ACCEPTOR> +#pragma instantiate Svc_Handler<ACE_TLI_STREAM> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else int diff --git a/examples/Connection/non_blocking/test_tli_connector.cpp b/examples/Connection/non_blocking/test_tli_connector.cpp index 7f1567582fd..31846345746 100644 --- a/examples/Connection/non_blocking/test_tli_connector.cpp +++ b/examples/Connection/non_blocking/test_tli_connector.cpp @@ -10,10 +10,10 @@ typedef Peer_Handler<ACE_TLI_STREAM> PEER_HANDLER; typedef IPC_Client<PEER_HANDLER, ACE_TLI_CONNECTOR> IPC_CLIENT; - -int -main (int argc, char *argv[]) -{ + +int +main (int argc, char *argv[]) +{ // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); @@ -21,11 +21,11 @@ main (int argc, char *argv[]) if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); - + return peer_connector.svc (); -} +} -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<PEER_HANDLER, ACE_TLI_CONNECTOR>; template class ACE_Svc_Handler<ACE_TLI_STREAM, ACE_SYNCH>; template class ACE_Svc_Tuple<PEER_HANDLER>; @@ -34,7 +34,17 @@ template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_S template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX>; template class IPC_Client<PEER_HANDLER, ACE_TLI_CONNECTOR>; template class Peer_Handler<ACE_TLI_STREAM>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<PEER_HANDLER, ACE_TLI_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_TLI_STREAM, ACE_SYNCH> +#pragma instantiate ACE_Svc_Tuple<PEER_HANDLER> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<PEER_HANDLER> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate IPC_Client<PEER_HANDLER, ACE_TLI_CONNECTOR> +#pragma instantiate Peer_Handler<ACE_TLI_STREAM> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else int diff --git a/examples/IOStream/client/iostream_client.cpp b/examples/IOStream/client/iostream_client.cpp index 919611794ff..0227f96d20c 100644 --- a/examples/IOStream/client/iostream_client.cpp +++ b/examples/IOStream/client/iostream_client.cpp @@ -48,8 +48,12 @@ int main (int argc, char *argv[]) #if !defined (ACE_LACKS_ACE_IOSTREAM) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_IOStream_T <ACE_SOCK_Stream>; template class ACE_Streambuf_T <ACE_SOCK_Stream>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_IOStream_T <ACE_SOCK_Stream> +#pragma instantiate ACE_Streambuf_T <ACE_SOCK_Stream> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* !ACE_LACKS_ACE_IOSTREAM */ diff --git a/examples/IOStream/server/iostream_server.cpp b/examples/IOStream/server/iostream_server.cpp index d0874f16503..88d5ea1e4f5 100644 --- a/examples/IOStream/server/iostream_server.cpp +++ b/examples/IOStream/server/iostream_server.cpp @@ -18,10 +18,10 @@ typedef ACE_IOStream_T<ACE_SOCK_Stream> ACE_SOCK_IOStream ; // Create a service handler object based on our new // iostream/SOCK_Stream hybrid. -typedef ACE_Svc_Handler<ACE_SOCK_IOStream, ACE_INET_Addr, ACE_NULL_SYNCH> +typedef ACE_Svc_Handler<ACE_SOCK_IOStream, ACE_INET_Addr, ACE_NULL_SYNCH> Service_Handler; -class Handler : public Service_Handler +class Handler : public Service_Handler // = TITLE // Extend the <Service_Handler> object to do our bidding. All of // this is fairly standard until we get to the <handle_input> @@ -30,30 +30,30 @@ class Handler : public Service_Handler { public: Handler (void) {} - + virtual int open (void *) { - if (this->reactor () ->register_handler - (this, ACE_Event_Handler::READ_MASK) == - 1) - ACE_ERROR_RETURN ((LM_ERROR, - "registering connection handler with ACE_Reactor\n"), + if (this->reactor () ->register_handler + (this, ACE_Event_Handler::READ_MASK) == - 1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering connection handler with ACE_Reactor\n"), - 1); return 0; } - + virtual void destroy (void) { this->peer ().close (); delete this ; } - + virtual int close (u_long) { this->destroy (); return 0 ; } - + virtual int handle_input (ACE_HANDLE) { int i; @@ -61,7 +61,7 @@ public: #if defined (ACE_HAS_STRING_CLASS) String s; - + if (!(this -> peer () >> i >> f >> s)) { cerr << "Error getting data" << endl ; @@ -106,7 +106,7 @@ public: typedef ACE_Acceptor<Handler, ACE_SOCK_ACCEPTOR> Logging_Acceptor; #endif /* !ACE_LACKS_ACE_IOSTREAM */ -int +int main (int argc, char *argv []) { #if !defined (ACE_LACKS_ACE_IOSTREAM) @@ -125,16 +125,16 @@ main (int argc, char *argv []) ACE_ERROR_RETURN ((LM_ERROR, "%p\n"), -1); Logging_Acceptor peer_acceptor ; - + if (peer_acceptor.open (ACE_INET_Addr (argc > 1 ? atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT)) == - 1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), - 1); - else if (ACE_Reactor::instance ()->register_handler - (&peer_acceptor, ACE_Event_Handler::READ_MASK) == - 1) + else if (ACE_Reactor::instance ()->register_handler + (&peer_acceptor, ACE_Event_Handler::READ_MASK) == - 1) ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), - 1); - + ACE_DEBUG ((LM_DEBUG, " (%P|%t) starting up daemon\n")); - + ACE_Reactor::run_event_loop (); ACE_DEBUG ((LM_DEBUG, " (%P|%t) shutting down server daemon\n")); @@ -147,10 +147,16 @@ main (int argc, char *argv []) #if !defined (ACE_LACKS_ACE_IOSTREAM) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor <Handler, ACE_SOCK_ACCEPTOR>; template class ACE_IOStream_T <ACE_SOCK_Stream>; template class ACE_Streambuf_T <ACE_SOCK_Stream>; template class ACE_Svc_Handler <ACE_SOCK_IOStream, ACE_INET_Addr, ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor <Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_IOStream_T <ACE_SOCK_Stream> +#pragma instantiate ACE_Streambuf_T <ACE_SOCK_Stream> +#pragma instantiate ACE_Svc_Handler <ACE_SOCK_IOStream, ACE_INET_Addr, ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* !ACE_LACKS_ACE_IOSTREAM */ diff --git a/examples/IPC_SAP/UPIPE_SAP/ex2.cpp b/examples/IPC_SAP/UPIPE_SAP/ex2.cpp index 351fb92c21b..4898f7240f4 100644 --- a/examples/IPC_SAP/UPIPE_SAP/ex2.cpp +++ b/examples/IPC_SAP/UPIPE_SAP/ex2.cpp @@ -24,7 +24,7 @@ static void * supplier (void *) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (&thr_mgr); ACE_UPIPE_Stream s_stream; ACE_UPIPE_Addr c_addr ("pattern"); @@ -39,7 +39,7 @@ supplier (void *) ACE_UPIPE_Connector con; if (con.connect (s_stream, c_addr) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "ACE_UPIPE_Acceptor.connect failed")); // Test asynchronisity. @@ -47,8 +47,8 @@ supplier (void *) for (int j = 0; j < iterations; j++) { - ACE_Message_Block *mb_p = - new ACE_Message_Block (size, ACE_Message_Block::MB_DATA, + ACE_Message_Block *mb_p = + new ACE_Message_Block (size, ACE_Message_Block::MB_DATA, (ACE_Message_Block *) 0, mybuf); if (s_stream.send (mb_p) == -1) @@ -65,7 +65,7 @@ supplier (void *) cout << "error put" << endl; return 0; } - + s_stream.close (); return 0; } @@ -74,7 +74,7 @@ static void * consumer (void *) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (&thr_mgr); ACE_UPIPE_Stream c_stream; // Set the high water mark to size to achieve optimum performance. @@ -98,7 +98,7 @@ consumer (void *) ACE_DEBUG ((LM_DEBUG, "(%t) consumer starting accept\n")); if (acc.accept (c_stream) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "ACE_UPIPE_Acceptor.accept failed")); // time measurement @@ -108,7 +108,7 @@ consumer (void *) int received_messages = 0; - for (ACE_Message_Block *mb = 0; + for (ACE_Message_Block *mb = 0; c_stream.recv (mb) != -1 && mb->size () != 0; mb->release ()) received_messages++; @@ -116,7 +116,7 @@ consumer (void *) ACE_OS::time (&currsec); time_t secs = (time_t) currsec - start; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Transferred %d blocks of size %d\n" "The program ran %d seconds\n", received_messages, size, secs)); @@ -125,7 +125,7 @@ consumer (void *) return 0; } -int +int main (int argc, char *argv[]) { size = argc > 1 ? ACE_OS::atoi (argv[1]) : 32; @@ -136,13 +136,13 @@ main (int argc, char *argv[]) THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ( (LM_ERROR, "%p\n", "spawn"), 1); - // Wait for producer and consumer threads to exit. + // Wait for producer and consumer threads to exit. thr_mgr.wait (); return 0; } #else -int +int main (int, char *[]) { ACE_ERROR ( (LM_ERROR, "threads not supported on this platform\n")); @@ -151,6 +151,9 @@ main (int, char *[]) #endif /* ACE_HAS_THREADS */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class auto_builtin_ptr <char>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate auto_builtin_ptr <char> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/IPC_SAP/UPIPE_SAP/ex3.cpp b/examples/IPC_SAP/UPIPE_SAP/ex3.cpp index 8308532a226..e947f5889f9 100644 --- a/examples/IPC_SAP/UPIPE_SAP/ex3.cpp +++ b/examples/IPC_SAP/UPIPE_SAP/ex3.cpp @@ -25,17 +25,17 @@ static void * supplier (void *) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (&thr_mgr); ACE_UPIPE_Stream s_stream; ACE_UPIPE_Addr c_addr ("pattern"); ACE_UPIPE_Connector con; - + ACE_DEBUG ((LM_DEBUG, "(%t) supplier starting connect thread\n")); if (con.connect (s_stream, c_addr) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "ACE_UPIPE_Acceptor.connect failed")); auto_builtin_ptr <char> mybuf = new char[size]; @@ -58,7 +58,7 @@ supplier (void *) return 0; } - s_stream.close (); + s_stream.close (); return 0; } @@ -66,13 +66,13 @@ static void * consumer (void *) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (&thr_mgr); ACE_UPIPE_Stream c_stream; ACE_UPIPE_Addr serv_addr ("pattern"); // Accept will wait up to 4 seconds - ACE_UPIPE_Acceptor acc (serv_addr); + ACE_UPIPE_Acceptor acc (serv_addr); ACE_DEBUG ((LM_DEBUG, "(%t) consumer spawning the supplier thread\n")); @@ -80,11 +80,11 @@ consumer (void *) if (thr_mgr.spawn (ACE_THR_FUNC (supplier), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 0); - + ACE_DEBUG ((LM_DEBUG, "(%t) consumer starting accept\n")); if (acc.accept (c_stream) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "ACE_UPIPE_Acceptor.accept failed")); // Ensure deletion upon exit. @@ -111,7 +111,7 @@ consumer (void *) ACE_OS::time (&currsec); time_t secs = (time_t) currsec - start; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Transferred %d blocks of size %d\n" "The program ran %d seconds\n", blocks, size, secs)); @@ -120,7 +120,7 @@ consumer (void *) return 0; } -int +int main (int argc, char *argv[]) { size = argc > 1 ? ACE_OS::atoi (argv[1]) : 32; @@ -136,7 +136,7 @@ main (int argc, char *argv[]) return 0; } #else -int +int main (int, char *[]) { ACE_ERROR ( (LM_ERROR, "threads not supported on this platform\n")); @@ -145,6 +145,9 @@ main (int, char *[]) #endif /* ACE_HAS_THREADS */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class auto_builtin_ptr <char>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate auto_builtin_ptr <char> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Logger/Acceptor-server/server_loggerd.cpp b/examples/Logger/Acceptor-server/server_loggerd.cpp index 6649af76424..ff57f51fa93 100644 --- a/examples/Logger/Acceptor-server/server_loggerd.cpp +++ b/examples/Logger/Acceptor-server/server_loggerd.cpp @@ -47,7 +47,7 @@ Options::parse_args (int argc, char *argv[]) for (int c; (c = get_opt ()) != -1; ) switch (c) { - case 'p': + case 'p': this->port_ = ACE_OS::atoi (get_opt.optarg); break; default: @@ -58,15 +58,15 @@ Options::parse_args (int argc, char *argv[]) // ---------------------------------------- // Our Reactor Singleton. -typedef ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> +typedef ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> REACTOR; // Our Options Singleton. -typedef ACE_Singleton<Options, ACE_Null_Mutex> +typedef ACE_Singleton<Options, ACE_Null_Mutex> OPTIONS; // Our ACE_Test_and_Set Singleton. -typedef ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex> +typedef ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex> QUIT_HANDLER; // ---------------------------------------- @@ -74,7 +74,7 @@ typedef ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_ class Logging_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> // = TITLE // Receive client message from the remote clients. - // + // // = DESCRIPTION // This class demonstrates how to receive messages from remote // clients using the notification mechanisms in the @@ -91,8 +91,8 @@ public: protected: // = Demultiplexing hooks. virtual int handle_input (ACE_HANDLE); - virtual int handle_timeout (const ACE_Time_Value &tv, - const void *arg); + virtual int handle_timeout (const ACE_Time_Value &tv, + const void *arg); private: char peer_name_[MAXHOSTNAMELEN + 1]; @@ -100,7 +100,7 @@ private: }; // Specialize a Logging Acceptor. -typedef ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR> +typedef ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR> Logging_Acceptor; // Default constructor. @@ -118,7 +118,7 @@ Logging_Handler::handle_timeout (const ACE_Time_Value &, return 0; } -// Perform the logging record receive. +// Perform the logging record receive. int Logging_Handler::handle_input (ACE_HANDLE) @@ -130,16 +130,16 @@ Logging_Handler::handle_input (ACE_HANDLE) // it as an exercise for the reader ;-). ssize_t len; - ssize_t n = this->peer ().recv ((void *) &len, sizeof len); + ssize_t n = this->peer ().recv ((void *) &len, sizeof len); switch (n) { case -1: ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", - "client logger", this->peer_name_), -1); + "client logger", this->peer_name_), -1); /* NOTREACHED */ case 0: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing log daemon at host %s (fd = %d)\n", this->peer_name_, this->get_handle ()), -1); /* NOTREACHED */ @@ -154,7 +154,7 @@ Logging_Handler::handle_input (ACE_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", "client logger", this->peer_name_), -1); /* NOTREACHED */ - + lp.decode (); if (lp.length () == n) @@ -180,28 +180,28 @@ int Logging_Handler::open (void *) { ACE_INET_Addr addr; - + if (this->peer ().get_remote_addr (addr) == -1) return -1; else { - ACE_OS::strncpy (this->peer_name_, - addr.get_host_name (), + ACE_OS::strncpy (this->peer_name_, + addr.get_host_name (), MAXHOSTNAMELEN + 1); - if (REACTOR::instance ()->register_handler + if (REACTOR::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1); else if (REACTOR::instance ()->schedule_timer - (this, - (const void *) this, - ACE_Time_Value (2), + (this, + (const void *) this, + ACE_Time_Value (2), ACE_Time_Value (2)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1); else - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", this->peer_name_)); return 0; } @@ -218,44 +218,52 @@ main (int argc, char *argv[]) // We need to pass in REACTOR::instance () here so that we don't use // the default ACE_Reactor::instance (). - if (peer_acceptor.open + if (peer_acceptor.open (ACE_INET_Addr (OPTIONS::instance ()->port ()), REACTOR::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); - else if (REACTOR::instance ()->register_handler + else if (REACTOR::instance ()->register_handler (&peer_acceptor, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); // Register QUIT_HANDLER to receive SIGINT commands. When received, // QUIT_HANDLER becomes "set" and thus, the event loop below will // exit. - else if (REACTOR::instance ()->register_handler + else if (REACTOR::instance ()->register_handler (SIGINT, QUIT_HANDLER::instance ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); // Run forever, performing logging service. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n")); // Perform logging service until QUIT_HANDLER receives SIGINT. while (QUIT_HANDLER::instance ()->is_set () == 0) REACTOR::instance ()->handle_events (); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n")); return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Logging_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Singleton<ACE_Reactor, ACE_Null_Mutex>; template class ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex>; template class ACE_Singleton<Options, ACE_Null_Mutex>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Logging_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> +#pragma instantiate ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex> +#pragma instantiate ACE_Singleton<Options, ACE_Null_Mutex> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Logger/simple-server/server_loggerd.cpp b/examples/Logger/simple-server/server_loggerd.cpp index 7846c4ed249..eb223750af0 100644 --- a/examples/Logger/simple-server/server_loggerd.cpp +++ b/examples/Logger/simple-server/server_loggerd.cpp @@ -38,7 +38,7 @@ main (int argc, char *argv[]) for (int c; (c = get_opt ()) != -1; ) switch (c) { - case 'p': + case 'p': addr.set (ACE_OS::atoi (get_opt.optarg)); break; default: @@ -47,28 +47,31 @@ main (int argc, char *argv[]) if (peer_acceptor.open (addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); - else if (REACTOR::instance ()->register_handler - (&peer_acceptor, + else if (REACTOR::instance ()->register_handler + (&peer_acceptor, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "registering service with ACE_Reactor\n"), + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), -1); // Run forever, performing logging service. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n")); while (!finished) REACTOR::instance ()->handle_events (); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n")); return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<ACE_Reactor, ACE_Null_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Misc/test_dump.cpp b/examples/Misc/test_dump.cpp index 5b67488b405..994cd204c7b 100644 --- a/examples/Misc/test_dump.cpp +++ b/examples/Misc/test_dump.cpp @@ -12,7 +12,7 @@ public: SOCK (void) { ACE_REGISTER_OBJECT (SOCK); } ~SOCK (void) { ACE_REMOVE_OBJECT; } - void dump (void) const { + void dump (void) const { cerr << "hello from SOCK = " << (u_long) this << endl; } @@ -25,7 +25,7 @@ public: SOCK_Acceptor (void) { ACE_REGISTER_OBJECT (SOCK_Acceptor); } ~SOCK_Acceptor (void) { ACE_REMOVE_OBJECT; } - void dump (void) const { + void dump (void) const { cerr << "hello from SOCK_Acceptor = " << (u_long) this << endl; } @@ -45,7 +45,7 @@ public: // ... }; -int +int main (void) { SOCK outer_sock; @@ -60,12 +60,17 @@ main (void) SOCK_Acceptor inner_acceptor; ACE_ODB::instance ()->dump_objects (); } - ACE_ODB::instance ()->dump_objects (); + ACE_ODB::instance ()->dump_objects (); return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Dumpable_Adapter<SOCK_Stream>; template class ACE_Dumpable_Adapter<SOCK>; template class ACE_Dumpable_Adapter<SOCK_Acceptor>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Dumpable_Adapter<SOCK_Stream> +#pragma instantiate ACE_Dumpable_Adapter<SOCK> +#pragma instantiate ACE_Dumpable_Adapter<SOCK_Acceptor> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Misc/test_set.cpp b/examples/Misc/test_set.cpp index e43d96bab82..b06f3d0fd76 100644 --- a/examples/Misc/test_set.cpp +++ b/examples/Misc/test_set.cpp @@ -2,11 +2,13 @@ #include "ace/Containers.h" -int +int main (int, char *[]) { return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Reactor/Misc/pingpong.cpp b/examples/Reactor/Misc/pingpong.cpp index e77ff89ab6d..a88fcbbb27b 100644 --- a/examples/Reactor/Misc/pingpong.cpp +++ b/examples/Reactor/Misc/pingpong.cpp @@ -11,7 +11,7 @@ % ./pingpong hello You should see lots of the following output: - + writing <4> [7860] writing <4> [7860] writing <4> [7860] @@ -70,7 +70,7 @@ Ping_Pong::Ping_Pong (char b[], ACE_HANDLE f) { *((int *) this->buf_) = (int) this->pid_; *((int *) (this->buf_ + sizeof (int))) = 0; - ACE_OS::strcpy (this->buf_ + (2 * sizeof (int)), b); + ACE_OS::strcpy (this->buf_ + (2 * sizeof (int)), b); this->buf_[this->buflen_ - 1] = '\n'; this->buf_[this->buflen_] = '\0'; } @@ -81,7 +81,7 @@ Ping_Pong::get_handle (void) const return this->handle_; } -int +int Ping_Pong::handle_input (ACE_HANDLE) { #if defined (ACE_HAS_STREAM_PIPES) @@ -92,11 +92,11 @@ Ping_Pong::handle_input (ACE_HANDLE) if (n != (ssize_t) this->buflen_) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) reading [%d] %p\n", handle_, "read"), -1); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) reading <%d> (%d) [%d] = %s\n", - this->handle_, - *(int *) this->buf_, - *(int *) (this->buf_ + sizeof (int)), + this->handle_, + *(int *) this->buf_, + *(int *) (this->buf_ + sizeof (int)), this->buf_ + (2 * sizeof (int)))); #else ssize_t n = ACE::recv (this->handle_, this->buf_, this->buflen_); @@ -113,7 +113,7 @@ Ping_Pong::handle_input (ACE_HANDLE) return 0; } -int +int Ping_Pong::handle_output (ACE_HANDLE) { #if defined (ACE_HAS_STREAM_PIPES) @@ -125,8 +125,8 @@ Ping_Pong::handle_output (ACE_HANDLE) return -1; else { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) writing <%d> [%d]\n", + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) writing <%d> [%d]\n", this->handle_, this->pid_)); return 0; } @@ -135,15 +135,15 @@ Ping_Pong::handle_output (ACE_HANDLE) return -1; else { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) writing <%d>\n", this->handle_)); return 0; } #endif /* ACE_HAS_STREAM_PIPES */ } -int -Ping_Pong::handle_timeout (const ACE_Time_Value &, +int +Ping_Pong::handle_timeout (const ACE_Time_Value &, const void *) { this->set (1); @@ -167,7 +167,7 @@ run_svc (ACE_HANDLE handle) // timer-based events. if (reactor.register_handler (&callback, - ACE_Event_Handler::READ_MASK + ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1 #if !defined (CHORUS) || reactor.register_handler (SIGINT, &callback) == -1 @@ -197,7 +197,7 @@ worker (void *arg) } #endif /* ACE_WIN32 */ -int +int main (int argc, char *argv[]) { ACE_LOG_MSG->open (argv[0]); @@ -213,8 +213,8 @@ main (int argc, char *argv[]) ACE_Pipe pipe (handles); #if defined (ACE_WIN32) || defined (CHORUS) - if (ACE_Thread::spawn (ACE_THR_FUNC (worker), - (void *) handles[0], + if (ACE_Thread::spawn (ACE_THR_FUNC (worker), + (void *) handles[0], THR_DETACHED) == -1 || ACE_Thread::spawn (ACE_THR_FUNC (worker), (void *) handles[1], @@ -239,6 +239,9 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Reactor/Misc/test_reactors.cpp b/examples/Reactor/Misc/test_reactors.cpp index 36a1d02cbf1..ddaf7a95f7f 100644 --- a/examples/Reactor/Misc/test_reactors.cpp +++ b/examples/Reactor/Misc/test_reactors.cpp @@ -24,7 +24,7 @@ public: virtual int svc (void); virtual int handle_input (ACE_HANDLE handle); - virtual int handle_close (ACE_HANDLE fd, + virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask); private: @@ -45,8 +45,8 @@ Test_Task::Test_Task (void) ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, reclock_); Test_Task::task_count_++; - ACE_DEBUG ((LM_DEBUG, - "(%t) TT+ Test_Task::task_count_ = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) TT+ Test_Task::task_count_ = %d\n", Test_Task::task_count_)); } @@ -54,31 +54,31 @@ Test_Task::~Test_Task (void) { ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, reclock_); - ACE_DEBUG ((LM_DEBUG, - "(%t) TT- Test_Task::task_count_ = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) TT- Test_Task::task_count_ = %d\n", Test_Task::task_count_)); } -int +int Test_Task::open (void *args) { this->reactor ((ACE_Reactor *) args); return this->activate (THR_NEW_LWP); } -int +int Test_Task::close (u_long) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, reclock_, -1); Test_Task::task_count_--; - ACE_DEBUG ((LM_DEBUG, - "(%t) close Test_Task::task_count_ = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) close Test_Task::task_count_ = %d\n", Test_Task::task_count_)); return 0; } -int +int Test_Task::svc (void) { for (int i = 0; i < NUM_INVOCATIONS; i++) @@ -89,14 +89,14 @@ Test_Task::svc (void) if (this->reactor ()->notify (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); - + // ACE_DEBUG ((LM_DEBUG, "(%t) leaving notify %d\n", i)); } return 0; } -int +int Test_Task::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { @@ -104,7 +104,7 @@ Test_Task::handle_close (ACE_HANDLE, return 0; } -int +int Test_Task::handle_input (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, "(%t) handle_input\n")); @@ -114,7 +114,7 @@ Test_Task::handle_input (ACE_HANDLE) if (this->handled_ == NUM_INVOCATIONS) { done_count--; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) handle_input, handled_ = %d, done_count = %d\n", this->handled_, (int) done_count)); } @@ -154,7 +154,7 @@ worker (void *args) return 0; } -int +int main (void) { ACE_Reactor *react1 = ACE_Reactor::instance (); @@ -168,11 +168,11 @@ main (void) tt2[i].open (react2); } - if (ACE_Thread_Manager::instance ()->spawn + if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (worker), (void *) react1, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); - else if (ACE_Thread_Manager::instance ()->spawn + else if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (worker), (void *) react2, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); @@ -182,12 +182,15 @@ main (void) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp index f08965d7832..76564e842f0 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp @@ -15,25 +15,25 @@ #endif /* __ACE_INLINE__ */ // Shorthand names. -#define SH SVC_HANDLER +#define SH SVC_HANDLER #define PR_AC_1 ACE_PEER_ACCEPTOR_1 #define PR_AC_2 ACE_PEER_ACCEPTOR_2 #define PR_ST_1 ACE_PEER_STREAM_1 #define PR_ST_2 ACE_PEER_STREAM_2 -template <class SH, PR_AC_1> +template <class SH, PR_AC_1> Handle_Thr_Acceptor<SH, PR_AC_2>::~Handle_Thr_Acceptor (void) { } -template <class SH, PR_AC_1> +template <class SH, PR_AC_1> Handle_Thr_Acceptor<SH, PR_AC_2>::Handle_Thr_Acceptor (void) : thr_flags_ (THR_DETACHED | THR_NEW_LWP) { } -template <class SH, PR_AC_1> int -Handle_Thr_Acceptor<SH, PR_AC_2>::info (char **strp, +template <class SH, PR_AC_1> int +Handle_Thr_Acceptor<SH, PR_AC_2>::info (char **strp, size_t length) const { char buf[BUFSIZ]; @@ -63,7 +63,7 @@ Handle_Thr_Acceptor<SH, PR_AC_2>::init (int argc, char *argv[]) for (int c; (c = get_opt ()) != -1; ) switch (c) { - case 'p': + case 'p': local_addr.set (ACE_OS::atoi (get_opt.optarg)); break; case 't': @@ -74,8 +74,8 @@ Handle_Thr_Acceptor<SH, PR_AC_2>::init (int argc, char *argv[]) } // Initialize the threading strategy. - if (this->thr_strategy_.open (&this->thr_mgr_, - this->thr_flags_, + if (this->thr_strategy_.open (&this->thr_mgr_, + this->thr_flags_, n_threads) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); @@ -88,10 +88,10 @@ Handle_Thr_Acceptor<SH, PR_AC_2>::init (int argc, char *argv[]) return 0; } -template <class SH, PR_AC_1> int +template <class SH, PR_AC_1> int Handle_Thr_Acceptor<SH, PR_AC_2>::fini (void) { - return ACE_Reactor::instance ()->remove_handler + return ACE_Reactor::instance ()->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK); } @@ -106,8 +106,8 @@ CLI_Stream<PR_ST_2>::close (u_long) { ACE_DEBUG ((LM_DEBUG, "(%t) client stream object closing down\n")); this->peer ().close (); - - // Must be allocated dynamically! + + // Must be allocated dynamically! delete this; return 0; } @@ -117,13 +117,13 @@ CLI_Stream<PR_ST_2>::open (void *) { ACE_INET_Addr sa; - ACE_DEBUG ((LM_DEBUG, "(%t) client handle = %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) client handle = %d\n", this->peer ().get_handle ())); if (this->peer ().get_remote_addr (sa) == -1) return -1; - ACE_DEBUG ((LM_DEBUG, "(%t) accepted at port %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) accepted at port %d\n", sa.get_port_number ())); return 0; } @@ -145,8 +145,8 @@ CLI_Stream<PR_ST_2>::svc (void) time_t t = ACE_OS::time (0L); ACE_OS::cuserid (login_name); - ACE_OS::sprintf (buf, "user %s %s", - login_name, + ACE_OS::sprintf (buf, "user %s %s", + login_name, ACE_OS::ctime ((const time_t *) &t)); if (this->peer ().send_n (buf, ACE_OS::strlen (buf) + 1) == -1) @@ -167,13 +167,13 @@ CLI_Stream<PR_ST_2>::svc (void) #if defined (ACE_HAS_TLI) #include "ace/TLI_Stream.h" #include "ace/TLI_Acceptor.h" -#define THR_STREAM ACE_TLI_STREAM -#define THR_ACCEPTOR ACE_TLI_ACCEPTOR +#define THR_STREAM ACE_TLI_STREAM +#define THR_ACCEPTOR ACE_TLI_ACCEPTOR #else #include "ace/SOCK_Stream.h" #include "ace/SOCK_Acceptor.h" -#define THR_STREAM ACE_SOCK_STREAM -#define THR_ACCEPTOR ACE_SOCK_ACCEPTOR +#define THR_STREAM ACE_SOCK_STREAM +#define THR_ACCEPTOR ACE_SOCK_ACCEPTOR #endif /* ACE_HAS_TLI */ #include "ace/INET_Addr.h" @@ -188,7 +188,7 @@ u_short HANDLE_THR_ACCEPTOR::DEFAULT_PORT_ = ACE_DEFAULT_THR_PORT; HANDLE_THR_ACCEPTOR remote_thr_stream; ACE_Service_Object_Type rts (&remote_thr_stream, "Remote_Thr_Stream"); -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<CLI_STREAM, THR_ACCEPTOR>; template class ACE_Accept_Strategy<CLI_STREAM, THR_ACCEPTOR>; template class ACE_Concurrency_Strategy<CLI_STREAM>; @@ -199,7 +199,19 @@ template class ACE_Svc_Handler<THR_STREAM, ACE_MT_SYNCH>; template class ACE_Thread_Strategy<CLI_STREAM>; template class CLI_Stream <THR_STREAM>; template class Handle_Thr_Acceptor<CLI_STREAM, THR_ACCEPTOR>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<CLI_STREAM, THR_ACCEPTOR> +#pragma instantiate ACE_Accept_Strategy<CLI_STREAM, THR_ACCEPTOR> +#pragma instantiate ACE_Concurrency_Strategy<CLI_STREAM> +#pragma instantiate ACE_Creation_Strategy<CLI_STREAM> +#pragma instantiate ACE_Scheduling_Strategy<CLI_STREAM> +#pragma instantiate ACE_Strategy_Acceptor<CLI_STREAM, THR_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<THR_STREAM, ACE_MT_SYNCH> +#pragma instantiate ACE_Thread_Strategy<CLI_STREAM> +#pragma instantiate CLI_Stream <THR_STREAM> +#pragma instantiate Handle_Thr_Acceptor<CLI_STREAM, THR_ACCEPTOR> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ #endif /* ACE_HANDLE_THR_STREAM_C */ 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 */ + diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp index 8b1b4e74a0a..2e1cbd933e0 100644 --- a/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp +++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp @@ -4,7 +4,7 @@ #include "test.h" -int +int main (void) { long pid = long (ACE_OS::getpid ()); @@ -13,9 +13,9 @@ main (void) Message_Data msg_data (pid, ACE_OS::cuserid (0), "did you get this?"); - ACE_Typed_SV_Message<Message_Data> send_msg (msg_data, - SRV_ID, - msg_data.length ()), + ACE_Typed_SV_Message<Message_Data> send_msg (msg_data, + SRV_ID, + msg_data.length ()), recv_msg (pid); if (msgque.send (send_msg) < 0) @@ -26,18 +26,22 @@ main (void) Message_Data &recv_msg_data = recv_msg.data (); - cout << "a message of length " + cout << "a message of length " << recv_msg_data.length () - << " received from server " - << recv_msg_data.pid () - << " (user " - << recv_msg_data.user () << "): " + << " received from server " + << recv_msg_data.pid () + << " (user " + << recv_msg_data.user () << "): " << recv_msg_data.text () << "\n"; return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Typed_SV_Message_Queue<Message_Data>; template class ACE_Typed_SV_Message<Message_Data>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Typed_SV_Message_Queue<Message_Data> +#pragma instantiate ACE_Typed_SV_Message<Message_Data> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp index 59fd705b33a..dbf265fd279 100644 --- a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp +++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp @@ -6,7 +6,7 @@ #include "test.h" // Must be global for signal Message... -static ACE_Typed_SV_Message_Queue<Message_Data> msgque +static ACE_Typed_SV_Message_Queue<Message_Data> msgque (SRV_KEY, ACE_Typed_SV_Message_Queue<Message_Data>::ACE_CREATE); extern "C" void @@ -17,8 +17,8 @@ handler (int) ACE_OS::exit (0); } -int -main (void) +int +main (void) { char *username = ACE_OS::cuserid (0); Message_Data msg_data ((int) ACE_OS::getpid (), username, "I received your message."); @@ -33,15 +33,15 @@ main (void) { if (msgque.recv (recv_msg) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "msgque.recv"), 1); - + Message_Data &recv_msg_data = recv_msg.data (); cout << "a msg of length " << recv_msg_data.length () - << " sent from client " - << recv_msg_data.pid () - << " (user " - << recv_msg_data.user () << "): " + << " sent from client " + << recv_msg_data.pid () + << " (user " + << recv_msg_data.user () << "): " << recv_msg_data.text () << "\n"; cout.flush (); @@ -55,7 +55,11 @@ main (void) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Typed_SV_Message_Queue<Message_Data>; template class ACE_Typed_SV_Message<Message_Data>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Typed_SV_Message_Queue<Message_Data> +#pragma instantiate ACE_Typed_SV_Message<Message_Data> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphores_1.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphores_1.cpp index 6830b49052d..32686eef1f6 100644 --- a/examples/System_V_IPC/SV_Semaphores/Semaphores_1.cpp +++ b/examples/System_V_IPC/SV_Semaphores/Semaphores_1.cpp @@ -78,15 +78,21 @@ main (void) #else int main (void) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "SYSV IPC is not supported on this platform\n")); return 0; } #endif /* ACE_HAS_SYSV_IPC */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Guard<ACE_SV_Semaphore_Simple>; template class ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple>; template class ACE_Read_Guard<ACE_SV_Semaphore_Simple>; template class ACE_Write_Guard<ACE_SV_Semaphore_Simple>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Guard<ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Read_Guard<ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Write_Guard<ACE_SV_Semaphore_Simple> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphores_2.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphores_2.cpp index d361bd5dd5e..deac90bc9c6 100644 --- a/examples/System_V_IPC/SV_Semaphores/Semaphores_2.cpp +++ b/examples/System_V_IPC/SV_Semaphores/Semaphores_2.cpp @@ -89,15 +89,21 @@ main (void) #else int main (void) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "SYSV IPC is not supported on this platform\n")); return 0; } #endif /* ACE_HAS_SYSV_IPC */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Guard<ACE_SV_Semaphore_Simple>; template class ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple>; template class ACE_Read_Guard<ACE_SV_Semaphore_Simple>; template class ACE_Write_Guard<ACE_SV_Semaphore_Simple>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Guard<ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Read_Guard<ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Write_Guard<ACE_SV_Semaphore_Simple> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Threads/auto_event.cpp b/examples/Threads/auto_event.cpp index 77842017675..1b1e1f36448 100644 --- a/examples/Threads/auto_event.cpp +++ b/examples/Threads/auto_event.cpp @@ -31,7 +31,7 @@ reader (void *arg) int& data = *(int *) arg; ACE_Thread_Control tc (ACE_Thread_Manager::instance ()); - + // Wait for writer to complete. ACE_DEBUG ((LM_DEBUG, "(%t) reader: waiting...... \n")); @@ -39,7 +39,7 @@ reader (void *arg) if (EVENT::instance ()->wait () == -1) { ACE_ERROR ((LM_ERROR, "thread wait failed")); - ACE_OS::exit (0); + ACE_OS::exit (0); } // Read shared data. @@ -55,7 +55,7 @@ writer (void *arg) int& data = *(int *) arg; ACE_Thread_Control tc (ACE_Thread_Manager::instance ()); - + // Calculate (work). ACE_DEBUG ((LM_DEBUG, "(%t) writer: working for %d secs\n", work_time)); ACE_OS::sleep (work_time); @@ -69,13 +69,13 @@ writer (void *arg) if (EVENT::instance ()->signal () == -1) { ACE_ERROR ((LM_ERROR, "thread wait failed")); - ACE_OS::exit (0); + ACE_OS::exit (0); } - + return 0; } -int +int main (int argc, char **argv) { // Shared data: set by writer, read by reader. @@ -90,26 +90,29 @@ main (int argc, char **argv) // Create reader thread. if (tm.spawn (reader, (void *) &data) == -1) ACE_ERROR_RETURN ((LM_ERROR, "thread create for reader failed"), -1); - + // Create writer thread. if (tm.spawn (writer, (void *) &data) == -1) ACE_ERROR_RETURN ((LM_ERROR, "thread create for writer failed"), -1); - + // Wait for both. if (tm.wait () == -1) ACE_ERROR_RETURN ((LM_ERROR, "thread wait failed"), -1); - else + else ACE_DEBUG ((LM_ERROR, "graceful exit\n")); return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<ACE_Auto_Event, ACE_Thread_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Singleton<ACE_Auto_Event, ACE_Thread_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Threads/barrier2.cpp b/examples/Threads/barrier2.cpp index d917b44d401..15cddd47a1c 100644 --- a/examples/Threads/barrier2.cpp +++ b/examples/Threads/barrier2.cpp @@ -29,10 +29,10 @@ class Worker_Task : public ACE_Task<ACE_MT_SYNCH> { public: - Worker_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, + Worker_Task (ACE_Thread_Manager *thr_mgr, + int n_threads, int inp_serialize = 1); - + virtual int Producer (void); // produce input for workers @@ -56,7 +56,7 @@ private: // = Not needed for this test. virtual int open (void *) { return 0; } virtual int close (u_long) {ACE_DEBUG ((LM_DEBUG,"(%t) in close of worker\n")); return 0; } - + int nt_; // Number of worker threads to run. int inp_serialize_; @@ -65,10 +65,10 @@ private: }; template <class BARRIER> -Worker_Task<BARRIER>::Worker_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int inp_serialize) - : ACE_Task<ACE_MT_SYNCH> (thr_mgr), +Worker_Task<BARRIER>::Worker_Task (ACE_Thread_Manager *thr_mgr, + int n_threads, + int inp_serialize) + : ACE_Task<ACE_MT_SYNCH> (thr_mgr), barrier_ (n_threads) { nt_ = n_threads; @@ -87,10 +87,10 @@ Worker_Task<BARRIER>::Worker_Task (ACE_Thread_Manager *thr_mgr, template <class BARRIER> int Worker_Task<BARRIER>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ +{ int result; if (this->inp_serialize_) - result = this->putq (mb, tv); + result = this->putq (mb, tv); else { static int iter = 0; @@ -104,8 +104,8 @@ Worker_Task<BARRIER>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) return result; } -template <class BARRIER> int -Worker_Task<BARRIER>::service (ACE_Message_Block *mb, int iter) +template <class BARRIER> int +Worker_Task<BARRIER>::service (ACE_Message_Block *mb, int iter) { int length = mb->length (); @@ -121,9 +121,9 @@ Worker_Task<BARRIER>::service (ACE_Message_Block *mb, int iter) // Iterate <n_iterations> time printing off a message and "waiting" // for all other threads to complete this iteration. -template <class BARRIER> int -Worker_Task<BARRIER>::svc (void) -{ +template <class BARRIER> int +Worker_Task<BARRIER>::svc (void) +{ // Note that the ACE_Task::svc_run () method automatically adds us // to the Thread_Manager when the thread begins. @@ -131,14 +131,14 @@ Worker_Task<BARRIER>::svc (void) // message with a length == 0, which signals us to quit. for (int iter = 1; ;iter++) - { + { ACE_Message_Block *mb = 0; int result = this->getq (mb); if (result == -1) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "(%t) in iteration %d\n", "error waiting for message in iteration", iter)); break; } @@ -179,7 +179,7 @@ Worker_Task<BARRIER>::Producer (void) return -1; } - return 0; + return 0; } template <class BARRIER>int @@ -205,7 +205,7 @@ Worker_Task<BARRIER>::input (ACE_Message_Block *mb) if (n <= 1) #else ACE_DEBUG ((LM_DEBUG,"(%t) press chars and enter to put a new message into task queue ...\n")); - if ((n = read (0, mb->rd_ptr (), mb->size ())) <= 1) + if ((n = read (0, mb->rd_ptr (), mb->size ())) <= 1) #endif // manual { // Send a shutdown message to the waiting threads and exit. @@ -233,21 +233,21 @@ Worker_Task<BARRIER>::input (ACE_Message_Block *mb) if (this->put (mb) == -1) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put")); } - return 0; + return 0; } -int +int main (int argc, char *argv[]) { int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; - + ACE_DEBUG ((LM_DEBUG,"(%t) worker threads running=%d\n",n_threads)); - - Worker_Task<BARRIER_TYPE> *worker_task = - new Worker_Task<BARRIER_TYPE> (ACE_Thread_Manager::instance (), - /*n_threads*/ 0,0); - + + Worker_Task<BARRIER_TYPE> *worker_task = + new Worker_Task<BARRIER_TYPE> (ACE_Thread_Manager::instance (), + /*n_threads*/ 0,0); + worker_task->Producer (); // Wait for all the threads to reach their exit point. @@ -260,12 +260,15 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class Worker_Task<ACE_Null_Barrier>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate Worker_Task<ACE_Null_Barrier> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Threads/future1.cpp b/examples/Threads/future1.cpp index a39ca86a10d..54cad1e5ace 100644 --- a/examples/Threads/future1.cpp +++ b/examples/Threads/future1.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Test_Future.cpp // @@ -13,8 +13,8 @@ // // = AUTHOR // Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt -// <schmidt@cs.wustl.edu> -// +// <schmidt@cs.wustl.edu> +// // ============================================================================ #include "ace/ACE.h" @@ -88,14 +88,14 @@ private: }; Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, - u_long new_param, - int new_count, + u_long new_param, + int new_count, ACE_Future<u_long> &new_result) : scheduler_ (new_Scheduler), param_ (new_param), count_ (new_count), future_result_ (new_result) -{ +{ ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work created\n")); } @@ -137,7 +137,7 @@ Method_Object_name::Method_Object_name (Scheduler *new_scheduler, Method_Object_name::~Method_Object_name (void) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_name will be deleted.\n")); } @@ -161,7 +161,7 @@ private: }; // Constructor. -Scheduler::Scheduler (const char *newname, +Scheduler::Scheduler (const char *newname, Scheduler *new_scheduler) { ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); @@ -178,7 +178,7 @@ Scheduler::~Scheduler (void) } // open -int +int Scheduler::open (void *) { task_count++; @@ -187,7 +187,7 @@ Scheduler::open (void *) } // close -int +int Scheduler::close (u_long) { ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s close\n", this->name_)); @@ -196,10 +196,10 @@ Scheduler::close (u_long) } // service.. -int +int Scheduler::svc (void) { - for (;;) + for (;;) { // Dequeue the next method object (we use an auto pointer in // case an exception is thrown in the <call>). @@ -216,7 +216,7 @@ Scheduler::svc (void) return 0; } -void +void Scheduler::end (void) { this->activation_queue_.enqueue (new Method_Object_end (this)); @@ -224,8 +224,8 @@ Scheduler::end (void) // Here's where the Work takes place. -u_long -Scheduler::work_i (u_long param, +u_long +Scheduler::work_i (u_long param, int count) { ACE_UNUSED_ARG (count); @@ -244,26 +244,26 @@ Scheduler::name_i (void) return the_name; } -ACE_Future<const char *> +ACE_Future<const char *> Scheduler::name (void) { - if (this->scheduler_) + if (this->scheduler_) // Delegate to the Scheduler. return this->scheduler_->name (); - else + else { ACE_Future<const char*> new_future; // @@ What happens if new fails here? - this->activation_queue_.enqueue + this->activation_queue_.enqueue (new Method_Object_name (this, new_future)); return new_future; } } -ACE_Future<u_long> -Scheduler::work (u_long newparam, +ACE_Future<u_long> +Scheduler::work (u_long newparam, int newcount) { if (this->scheduler_) { @@ -284,11 +284,11 @@ Scheduler::work (u_long newparam, static size_t n_loops = 100; int -main (int, char *[]) +main (int, char *[]) { Scheduler *andres, *peter, *helmut, *matias; - // Create active objects.. + // Create active objects.. // @@ Should "open" be subsumed within the constructor of // Scheduler()? ACE_NEW_RETURN (andres, Scheduler ("andres"), -1); @@ -302,7 +302,7 @@ main (int, char *[]) ACE_NEW_RETURN (matias, Scheduler ("matias", andres), -1); matias->open (); - for (size_t i = 0; i < n_loops; i++) + for (size_t i = 0; i < n_loops; i++) { { ACE_Future<u_long> fresulta, fresultb, fresultc, fresultd, fresulte; @@ -326,7 +326,7 @@ main (int, char *[]) fresulte = fresulta; - if (i % 3 == 0) + if (i % 3 == 0) { // Every 3rd time... disconnect the futures... // but "fresulte" should still contain the result... @@ -373,7 +373,7 @@ main (int, char *[]) matias->end (); ACE_OS::sleep (2); - + ACE_DEBUG ((LM_DEBUG, "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", (int) task_count, @@ -387,7 +387,7 @@ main (int, char *[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; template class ACE_Future<const char *>; template class ACE_Future<u_long>; @@ -395,10 +395,19 @@ template class ACE_Future_Rep<char const *>; template class ACE_Future_Rep<u_long>; template class auto_ptr<ACE_Method_Object>; template class auto_basic_ptr<ACE_Method_Object>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#pragma instantiate ACE_Future<const char *> +#pragma instantiate ACE_Future<u_long> +#pragma instantiate ACE_Future_Rep<char const *> +#pragma instantiate ACE_Future_Rep<u_long> +#pragma instantiate auto_ptr<ACE_Method_Object> +#pragma instantiate auto_basic_ptr<ACE_Method_Object> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Threads/future2.cpp b/examples/Threads/future2.cpp index 23886bc150d..e4ae3fa1773 100644 --- a/examples/Threads/future2.cpp +++ b/examples/Threads/future2.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Test_Future.cpp // @@ -13,7 +13,7 @@ // // = AUTHOR // Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt -// <schmidt@cs.wustl.edu> +// <schmidt@cs.wustl.edu> // // Modification History // Aug. 96; A.Kruse; dev. @@ -51,7 +51,7 @@ class Scheduler : public ACE_Task<ACE_MT_SYNCH> { // Every method object has to be able to access the private methods. - friend class Method_Object_work; + friend class Method_Object_work; friend class Method_Object_name; friend class Method_Object_end; public: @@ -101,14 +101,14 @@ private: }; Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, - u_long new_param, - int new_count, + u_long new_param, + int new_count, ACE_Future<u_long> &new_result) : scheduler_ (new_Scheduler), param_ (new_param), count_ (new_count), future_result_ (new_result) -{ +{ } Method_Object_work::~Method_Object_work (void) @@ -147,7 +147,7 @@ Method_Object_name::Method_Object_name (Scheduler *new_scheduler, Method_Object_name::~Method_Object_name (void) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, " (%t) Method_Object_name will be deleted.\n")); } @@ -185,7 +185,7 @@ Scheduler::~Scheduler (void) ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s will be destroyed\n", this->name_)); } -int +int Scheduler::open (void *) { scheduler_open_count++; @@ -193,7 +193,7 @@ Scheduler::open (void *) return this->activate (THR_BOUND); } -int +int Scheduler::close (u_long) { ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s close\n", this->name_)); @@ -201,11 +201,11 @@ Scheduler::close (u_long) return 0; } -int +int Scheduler::svc (void) { // Main event loop for this active object. - for (;;) + for (;;) { // Dequeue the next method object (we use an auto pointer in // case an exception is thrown in the <call>). @@ -222,15 +222,15 @@ Scheduler::svc (void) return 0; } -void +void Scheduler::end (void) { this->activation_queue_.enqueue (new Method_Object_end (this)); } // Here's where the Work takes place. -u_long -Scheduler::work_i (u_long param, +u_long +Scheduler::work_i (u_long param, int count) { ACE_UNUSED_ARG (count); @@ -249,21 +249,21 @@ Scheduler::name_i (void) return the_name; } -ACE_Future<char *> +ACE_Future<char *> Scheduler::name (void) { - if (this->scheduler_) + if (this->scheduler_) // Delegate to the other scheduler return this->scheduler_->name (); - else + else { ACE_Future<char*> new_future; - if (this->thr_count () == 0) + if (this->thr_count () == 0) { // This scheduler is inactive... so we execute the user // request right away... - + auto_ptr<ACE_Method_Object> mo (new Method_Object_name (this, new_future)); mo->call (); @@ -273,23 +273,23 @@ Scheduler::name (void) // @@ What happens if new fails here? this->activation_queue_.enqueue (new Method_Object_name (this, new_future)); - + return new_future; } } -ACE_Future<u_long> +ACE_Future<u_long> Scheduler::work (u_long newparam, int newcount) { - if (this->scheduler_) + if (this->scheduler_) return this->scheduler_->work (newparam, newcount); - else + else { ACE_Future<u_long> new_future; - if (this->thr_count () == 0) + if (this->thr_count () == 0) { - auto_ptr<ACE_Method_Object> mo + auto_ptr<ACE_Method_Object> mo (new Method_Object_work (this, newparam, newcount, new_future)); mo->call (); // Smart pointer destructor automatically deletes it. @@ -302,14 +302,14 @@ Scheduler::work (u_long newparam, int newcount) } } -static int +static int determine_iterations (void) { int n_iterations; ACE_DEBUG ((LM_DEBUG," (%t) determining the number of iterations...\n")); Scheduler *worker_a; - + ACE_NEW_RETURN (worker_a, Scheduler ("worker A"), -1); ACE_Time_Value tstart (ACE_OS::gettimeofday ()); @@ -329,7 +329,7 @@ determine_iterations (void) tend = ACE_OS::gettimeofday (); } - ACE_DEBUG ((LM_DEBUG," (%t) n_iterations %d\n", + ACE_DEBUG ((LM_DEBUG," (%t) n_iterations %d\n", (int) n_iterations)); worker_a->end (); @@ -347,7 +347,7 @@ test_active_object (int n_iterations) // futures to return values from an active object. Scheduler *worker_a; - Scheduler *worker_b; + Scheduler *worker_b; Scheduler *worker_c; ACE_NEW (worker_a, Scheduler ("worker A")); @@ -365,7 +365,7 @@ test_active_object (int n_iterations) // activated for (int i = 0; i < 2; i++) { - if (i == 1) + if (i == 1) { worker_a->open (); worker_b->open (); @@ -376,7 +376,7 @@ test_active_object (int n_iterations) ACE_Future<u_long> fresultb = worker_b->work (9013); ACE_Future<u_long> fresultc = worker_c->work (9013); - if (i == 0) + if (i == 0) { if (!fresulta.ready ()) ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker A is should be ready!!!\n")); @@ -495,7 +495,7 @@ test_timeout (int n_iterations) } int -main (int, char *[]) +main (int, char *[]) { int n_iterations = determine_iterations (); @@ -509,7 +509,7 @@ main (int, char *[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; template class ACE_Future<char *>; template class ACE_Future<u_long>; @@ -517,10 +517,19 @@ template class ACE_Future_Rep<char *>; template class ACE_Future_Rep<u_long>; template class auto_ptr<ACE_Method_Object>; template class auto_basic_ptr<ACE_Method_Object>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#pragma instantiate ACE_Future<char *> +#pragma instantiate ACE_Future<u_long> +#pragma instantiate ACE_Future_Rep<char *> +#pragma instantiate ACE_Future_Rep<u_long> +#pragma instantiate auto_ptr<ACE_Method_Object> +#pragma instantiate auto_basic_ptr<ACE_Method_Object> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Threads/reader_writer.cpp b/examples/Threads/reader_writer.cpp index 0319d5fc041..d43af5ab46f 100644 --- a/examples/Threads/reader_writer.cpp +++ b/examples/Threads/reader_writer.cpp @@ -23,10 +23,10 @@ static int n_readers = 6; static int n_writers = 2; // Thread id of last writer. -static volatile ACE_thread_t shared_thr_id; +static volatile ACE_thread_t shared_thr_id; // Lock for shared_thr_id. -static ACE_RW_Mutex rw_mutex; +static ACE_RW_Mutex rw_mutex; // Count of the number of readers and writers. ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers, current_writers; @@ -35,10 +35,10 @@ ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers, current_writers; static ACE_Thread_Manager thr_mgr; // Explain usage and exit. -static void +static void print_usage_and_die (void) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "usage: %n [-r n_readers] [-w n_writers] [-n iteration_count]\n")); ACE_OS::exit (1); } @@ -49,7 +49,7 @@ parse_args (int argc, char *argv[]) { ACE_Get_Opt get_opt (argc, argv, "r:w:n:l:"); - int c; + int c; while ((c = get_opt ()) != -1) switch (c) @@ -80,7 +80,7 @@ reader (void *) { ACE_Thread_Control tc (&thr_mgr); ACE_DEBUG ((LM_DEBUG, "(%t) reader starting\n")); - + for (int iterations = 1; iterations <= n_iterations; iterations++) { @@ -90,7 +90,7 @@ reader (void *) if (current_writers > 0) ACE_DEBUG ((LM_DEBUG, "(%t) writers found!!!\n")); - + ACE_thread_t thr_id = shared_thr_id; for (int loop = 1; loop <= n_loops; loop++) @@ -98,8 +98,8 @@ reader (void *) ACE_Thread::yield(); if (ACE_OS::thr_equal (shared_thr_id, thr_id) == 0) - ACE_DEBUG ((LM_DEBUG, - "(%t) somebody changed %d to %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) somebody changed %d to %d\n", thr_id, shared_thr_id)); } @@ -118,8 +118,8 @@ writer (void *) { ACE_Thread_Control tc (&thr_mgr); ACE_DEBUG ((LM_DEBUG, "(%t) writer starting\n")); - - for (int iterations = 1; + + for (int iterations = 1; iterations <= n_iterations; iterations++) { @@ -132,7 +132,7 @@ writer (void *) if (current_readers > 0) ACE_DEBUG ((LM_DEBUG, "(%t) readers found!!!\n")); - + ACE_thread_t self = ACE_Thread::self (); shared_thr_id = self; @@ -141,7 +141,7 @@ writer (void *) ACE_Thread::yield(); if (ACE_OS::thr_equal (shared_thr_id, self) == 0) - ACE_DEBUG ((LM_DEBUG, "(%t) somebody wrote on my data %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) somebody wrote on my data %d\n", shared_thr_id)); } @@ -174,15 +174,21 @@ int main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; template class ACE_Guard<ACE_RW_Mutex>; template class ACE_Read_Guard<ACE_RW_Mutex>; template class ACE_Write_Guard<ACE_RW_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#pragma instantiate ACE_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_RW_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Threads/task_two.cpp b/examples/Threads/task_two.cpp index 133d3a69852..a0028775724 100644 --- a/examples/Threads/task_two.cpp +++ b/examples/Threads/task_two.cpp @@ -39,31 +39,31 @@ private: ACE_Thread_Mutex Task_Test::lock_; -int +int Task_Test::open (void *) { ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Task_Test::lock_, -1); task_count++; - ACE_DEBUG ((LM_DEBUG, "(%t) creating Task_Test, task count = %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) creating Task_Test, task count = %d\n", (int) task_count)); return this->activate (THR_BOUND); } -int +int Task_Test::close (u_long) { ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Task_Test::lock_, -1); task_count--; - ACE_DEBUG ((LM_DEBUG, "(%t) destroying Task_Test, task count = %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) destroying Task_Test, task count = %d\n", (int) task_count)); wait_count--; return 0; } -int +int Task_Test::svc (void) { wait_count++; @@ -81,7 +81,7 @@ Task_Test::svc (void) return 0; } -int +int main (int argc, char *argv[]) { n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : default_threads; @@ -91,11 +91,11 @@ main (int argc, char *argv[]) for (int i = 1; i <= n_iterations; i++) { - ACE_DEBUG ((LM_DEBUG, "(%t) iteration = %d, max_count %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) iteration = %d, max_count %d\n", i, (int) max_count)); max_count = 0; - ACE_DEBUG ((LM_DEBUG, "(%t) starting %d task%s\n", + ACE_DEBUG ((LM_DEBUG, "(%t) starting %d task%s\n", n_threads, n_threads == 1 ? "" : "s")); // Launch the new tasks. @@ -109,14 +109,14 @@ main (int argc, char *argv[]) // Wait for initialization to kick in. while (max_count == 0) ACE_Thread::yield (); - + ACE_DEBUG ((LM_DEBUG, "(%t) waiting for threads to finish\n")); // Wait for the threads to finish this iteration. while (max_count != n_threads && wait_count != 0) ACE_Thread::yield (); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) iteration %d finished, max_count %d, wait_count %d, waiting for tasks to exit\n", i, (int) max_count, (int) wait_count)); @@ -134,12 +134,15 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/examples/Threads/thread_specific.cpp b/examples/Threads/thread_specific.cpp index b1c3bc0e895..ee103c1d742 100644 --- a/examples/Threads/thread_specific.cpp +++ b/examples/Threads/thread_specific.cpp @@ -17,14 +17,14 @@ class Errno public: int error (void) { return this->errno_; } void error (int i) { this->errno_ = i; } - + int line (void) { return this->lineno_; } void line (int l) { this->lineno_ = l; } // Errno::flags_ is a static variable, so we've got to protect it // with a mutex since it isn't kept in thread-specific storage. - int flags (void) - { + int flags (void) + { ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1); return Errno::flags_; @@ -39,13 +39,13 @@ public: private: // = errno_ and lineno_ will be thread-specific data so they don't - // need a lock. + // need a lock. int errno_; int lineno_; static int flags_; #if defined (ACE_HAS_THREADS) - // flags_ needs a lock. + // flags_ needs a lock. static ACE_Thread_Mutex lock_; #endif /* ACE_HAS_THREADS */ }; @@ -66,7 +66,7 @@ typedef ACE_TSS_Guard<ACE_Thread_Mutex> GUARD; typedef ACE_Guard<ACE_Null_Mutex> GUARD; #endif /* ACE_HAS_THREADS */ -extern "C" void +extern "C" void cleanup (void *ptr) { ACE_DEBUG ((LM_DEBUG, "(%t) in cleanup, ptr = %x\n", ptr)); @@ -166,14 +166,14 @@ worker (void *c) return 0; } -extern "C" void +extern "C" void handler (int signum) { ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); ACE_Thread_Manager::instance ()->exit (0); } -int +int main (int argc, char *argv[]) { // The Service_Config must be the first object defined in main... @@ -187,8 +187,8 @@ main (int argc, char *argv[]) ACE_UNUSED_ARG (sa); #if defined (ACE_HAS_THREADS) - if (ACE_Thread_Manager::instance ()->spawn_n (threads, - ACE_THR_FUNC (&worker), + if (ACE_Thread_Manager::instance ()->spawn_n (threads, + ACE_THR_FUNC (&worker), (void *) count, THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Thread_Manager::spawn_n"), -1); @@ -200,15 +200,18 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_TSS<Errno>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_TSS<Errno> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (void) { - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "ACE doesn't support support threads on this platform (yet)\n"), -1); } diff --git a/examples/Threads/tss1.cpp b/examples/Threads/tss1.cpp index 49bb1441f80..d7f8bfed8d0 100644 --- a/examples/Threads/tss1.cpp +++ b/examples/Threads/tss1.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // TSS_Test.cpp // @@ -18,7 +18,7 @@ // // = AUTHOR // Detlef Becker -// +// // ============================================================================ #include "ace/Service_Config.h" @@ -35,13 +35,13 @@ class Errno public: int error (void) { return this->errno_; } void error (int i) { this->errno_ = i; } - + int line (void) { return this->lineno_; } void line (int l) { this->lineno_ = l; } // Errno::flags_ is a static variable, so we've got to protect it // with a mutex since it isn't kept in thread-specific storage. - int flags (void) { + int flags (void) { ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_Mon, Errno::lock_, -1)); return Errno::flags_; @@ -56,13 +56,13 @@ public: private: // = errno_ and lineno_ will be thread-specific data so they don't - // need a lock. + // need a lock. int errno_; int lineno_; static int flags_; #if defined (ACE_HAS_THREADS) - // flags_ needs a lock. + // flags_ needs a lock. static ACE_Thread_Mutex lock_; #endif /* ACE_HAS_THREADS */ }; @@ -106,7 +106,7 @@ public: virtual int close (u_long args = 0); }; -template <ACE_SYNCH_1> int +template <ACE_SYNCH_1> int Tester<ACE_SYNCH_2>::svc (void) { ACE_DEBUG ((LM_DEBUG, "(%t) svc: setting error code to 1\n")); @@ -115,14 +115,14 @@ Tester<ACE_SYNCH_2>::svc (void) for (int i = 0; i < iterations; i++) // Print out every tenth iteration. if ((i % 10) == 1) - ACE_DEBUG ((LM_DEBUG, "(%t) error = %d\n", TSS_Error->error ())); + ACE_DEBUG ((LM_DEBUG, "(%t) error = %d\n", TSS_Error->error ())); this->close (); return 0; } -template <ACE_SYNCH_1> int +template <ACE_SYNCH_1> int Tester<ACE_SYNCH_2>::open (void *) { // Make this an Active Object. @@ -141,7 +141,7 @@ int Tester<ACE_SYNCH_2>::close (u_long) return 0; } -int +int main (int, char *[]) { Tester<ACE_MT_SYNCH> tester; @@ -168,16 +168,20 @@ main (int, char *[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_TSS<Errno>; template class Tester<ACE_MT_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_TSS<Errno> +#pragma instantiate Tester<ACE_MT_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (void) { - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "ACE doesn't support support threads on this platform (yet)\n"), -1); } diff --git a/examples/Threads/tss2.cpp b/examples/Threads/tss2.cpp index f64577f4166..5ed163d5300 100644 --- a/examples/Threads/tss2.cpp +++ b/examples/Threads/tss2.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // TSS_Test.cpp // @@ -14,7 +14,7 @@ // // = AUTHOR // Prashant Jain and Doug Schmidt -// +// // ============================================================================ #include "TSS_Data.h" @@ -52,7 +52,7 @@ TSS_Obj::~TSS_Obj (void) Test_Task::Test_Task (void) { Test_Task::count_++; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Test_Task+: %d\n", (int) Test_Task::count_)); } @@ -60,7 +60,7 @@ Test_Task::~Test_Task (void) { Test_Task::count_--; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Test_Task-: %d\n", (int) Test_Task::count_)); Test_Task::wait_count_--; } @@ -77,7 +77,7 @@ Test_Task::svc (void *arg) Test_Task::wait_count_++; Test_Task::max_count_++; - ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting (data = %u)\n", + ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting (data = %u)\n", arg)); // Do a bunch of set operations on the TSS data just to make sure @@ -89,7 +89,7 @@ Test_Task::svc (void *arg) ACE_Thread::yield (); } - ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting finished (data = %u)\n", + ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting finished (data = %u)\n", arg)); #if 0 @@ -101,7 +101,7 @@ Test_Task::svc (void *arg) return 0; } -int +int Test_Task::open (void *arg) { if (ACE_Thread::spawn (Test_Task::svc, arg) == -1) @@ -110,18 +110,18 @@ Test_Task::open (void *arg) return 0; } -int +int main (int argc, char *argv[]) { num_tasks = argc > 1 ? atoi (argv[1]) : MAX_TASKS; Test_Task **task_arr; - + ACE_NEW_RETURN (task_arr, Test_Task *[num_tasks], -1); for (int i = 0; i < MAX_ITERATIONS; i++) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) ********* iteration %d **********\n" "Test_Task::max_count_ %d\n", i, @@ -149,17 +149,17 @@ main (int argc, char *argv[]) for (;;) { - if (!(Test_Task::max_count_ == num_tasks + if (!(Test_Task::max_count_ == num_tasks && Test_Task::wait_count_ == 0)) { ACE_Thread::yield (); continue; } - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Test_Task::max_count_ = %d," " Test_Task::wait_count_ = %d", (int) Test_Task::max_count_, - (int) Test_Task::wait_count_)); + (int) Test_Task::wait_count_)); break; } @@ -169,17 +169,24 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; template class ACE_Atomic_Op<ACE_Token, int>; template class ACE_TSS<TSS_Data>; template class ACE_TSS<TSS_Obj>; template class ACE_TSS_Singleton<TSS_Data, ACE_SYNCH_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#pragma instantiate ACE_Atomic_Op<ACE_Token, int> +#pragma instantiate ACE_TSS<TSS_Data> +#pragma instantiate ACE_TSS<TSS_Obj> +#pragma instantiate ACE_TSS_Singleton<TSS_Data, ACE_SYNCH_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/netsvcs/clients/Naming/Client/Client_Test.cpp b/netsvcs/clients/Naming/Client/Client_Test.cpp index 36fd6ba1317..e26416f7459 100644 --- a/netsvcs/clients/Naming/Client/Client_Test.cpp +++ b/netsvcs/clients/Naming/Client/Client_Test.cpp @@ -13,70 +13,70 @@ public: int open (void); // Cache reactor and then register self with reactor - + int close (void); // Close things down and free up resources. - + virtual int handle_input (ACE_HANDLE handle); // Handle user entered commands virtual int init (int argc, char *argv[]); // Initialize name options and naming context when dynamically // linked. - + virtual int fini (void); // Close down the test when dynamically unlinked. - + void list_options (void); // Print name options - + int bind (char *key, char *value, char *type = ""); // Bind a key to a value - + int unbind (char *key); // Unbind a name binding - + int rebind (char *key, char *value, char *type = ""); // Rebind a name binding - + int find (char *key); // Find the value associated with a key - + int list_names (char *pattern); // Find all names that match pattern - + int list_values (char *pattern); // Find all values that match pattern - + int list_types (char *pattern); // Find all types that match pattern - + int list_name_entries (char *pattern); // Find all names that match pattern - + int list_value_entries (char *pattern); // Find all values that match pattern int list_type_entries (char *pattern); // Find all types that match pattern - + private: ACE_Name_Options *name_options_; // Name Options associated with the Naming Context - + void display_menu (void); // Display user menu - + int set_proc_local (void); // Set options to use PROC_LOCAL naming context - + int set_node_local (void); // Set options to use NODE_LOCAL naming context - + int set_host (char *hostname, int port); - // Set options to use NET_LOCAL naming context + // Set options to use NET_LOCAL naming context // specifying host name and port number - + int quit (void); // Gracefully exit }; @@ -103,7 +103,7 @@ Client_Test::Client_Test (void) ACE_DEBUG ((LM_DEBUG, "Client_Test::Client_Test\n")); } -int +int Client_Test::init (int /* argc */, char * /* argv */ []) { ACE_DEBUG ((LM_DEBUG, "Client_Test::init\n")); @@ -130,12 +130,12 @@ int Client_Test::close (void) { // Deregister this handler with the ACE_Reactor. - return ACE_Reactor::instance ()->remove_handler - (ACE_STDIN, + return ACE_Reactor::instance ()->remove_handler + (ACE_STDIN, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK); } -int +int Client_Test::fini (void) { ACE_DEBUG ((LM_DEBUG, "Client_Test::fini\n")); @@ -155,10 +155,10 @@ Client_Test::handle_input (ACE_HANDLE) if (::scanf ("%s", option) <= 0) { - ACE_ERROR_RETURN ((LM_ERROR, "%p Try again!\n", + ACE_ERROR_RETURN ((LM_ERROR, "%p Try again!\n", "Client_Test::handle_input"), 0); } - + int result = -1; switch (isupper (option[0]) ? tolower (option[0]) : option[0]) @@ -316,7 +316,7 @@ Client_Test::display_menu (void) void Client_Test::list_options (void) { -// ACE_DEBUG ((LM_DEBUG, " *** Process Name is %s ***\n", +// ACE_DEBUG ((LM_DEBUG, " *** Process Name is %s ***\n", // this->name_options_->process_name ())); switch (this->name_options_->context ()) { @@ -327,16 +327,16 @@ Client_Test::list_options (void) ACE_DEBUG ((LM_DEBUG, " *** Using Node Local Database\n")); break; case ACE_Naming_Context::NET_LOCAL: - ACE_DEBUG ((LM_DEBUG, " *** Hostname: %s\n", + ACE_DEBUG ((LM_DEBUG, " *** Hostname: %s\n", this->name_options_->nameserver_host ())); - ACE_DEBUG ((LM_DEBUG, " *** Port Number: %d\n", + ACE_DEBUG ((LM_DEBUG, " *** Port Number: %d\n", this->name_options_->nameserver_port ())); break; - default: + default: assert (!"shouldn't occur!\n"); /* NOTREACHED */ } - ACE_DEBUG ((LM_DEBUG, " *** Namespace directory is %s ***\n", + ACE_DEBUG ((LM_DEBUG, " *** Namespace directory is %s ***\n", this->name_options_->namespace_dir ())); } @@ -360,7 +360,7 @@ Client_Test::set_node_local (void) return NAMING_CONTEXT ()->open (ACE_Naming_Context::NODE_LOCAL); } -int +int Client_Test::set_host (char* hostname, int port) { // Close down original name space @@ -370,18 +370,18 @@ Client_Test::set_host (char* hostname, int port) // Set Name Options this->name_options_->nameserver_host (hostname); this->name_options_->nameserver_port (port); - + return NAMING_CONTEXT ()->open (ACE_Naming_Context::NET_LOCAL); } -int +int Client_Test::quit (void) { // Send ourselves a SIGINT! return ACE_OS::kill (ACE_OS::getpid (), SIGINT); } -int +int Client_Test::bind (char* key, char* value, char* type) { if (NAMING_CONTEXT ()->bind (key, value, type) != 0) @@ -390,7 +390,7 @@ Client_Test::bind (char* key, char* value, char* type) return 0; } -int +int Client_Test::unbind (char* key) { if (NAMING_CONTEXT ()->unbind (key) != 0) @@ -399,7 +399,7 @@ Client_Test::unbind (char* key) return 0; } -int +int Client_Test::rebind (char* key, char* value, char* type) { int result = NAMING_CONTEXT ()->rebind (key, value, type ); @@ -540,7 +540,7 @@ Client_Test::list_type_entries (char *pattern) } -int +int Client_Test::find (char *key) { char *value = 0; @@ -551,8 +551,8 @@ Client_Test::find (char *key) "Client_Test::list_find", key), 0); else { - ACE_DEBUG ((LM_DEBUG, - "Binding for %s : value = %s\ttype = %s\n", + ACE_DEBUG ((LM_DEBUG, + "Binding for %s : value = %s\ttype = %s\n", key, value, type)); if (type) delete [] type; @@ -561,6 +561,9 @@ Client_Test::find (char *key) } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Dynamic_Service<ACE_Naming_Context>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Dynamic_Service<ACE_Naming_Context> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/netsvcs/clients/Tokens/manual/manual.cpp b/netsvcs/clients/Tokens/manual/manual.cpp index de9282ffc21..37ea73eaf15 100644 --- a/netsvcs/clients/Tokens/manual/manual.cpp +++ b/netsvcs/clients/Tokens/manual/manual.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // examples -// +// // = FILENAME // manual.cpp // @@ -13,7 +13,7 @@ // // = AUTHOR // Tim Harrison -// +// // ============================================================================ #include "ace/OS.h" @@ -42,7 +42,7 @@ public: int parse_args (int argc, char *argv[]); // Parse command-line arguments. - + int open (int argc, char *argv[]); // Register with whatever event dispatcher is needed and run. @@ -78,7 +78,7 @@ private: COLLECTIONS collections_; // A collection for each <tid>. - + char *server_host_; int server_port_; int ignore_deadlock_; @@ -93,7 +93,7 @@ STDIN_Token::STDIN_Token (void) debug_ (0), remote_ (0) { -} +} int STDIN_Token::parse_args (int argc, char *argv[]) @@ -123,7 +123,7 @@ STDIN_Token::parse_args (int argc, char *argv[]) case 'u': // usage: fallthrough default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-h <remote host>]\n" "[-p <remote port>]\n" @@ -146,18 +146,18 @@ STDIN_Token::open (int argc, char *argv[]) return -1; // Register for signals. - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (SIGINT, this) == -1) ACE_DEBUG ((LM_DEBUG, "Can't register signal handler\n")); #if (ACE_WIN32) - + #else // Register for STDIN events with Reactor. if (ACE_Reactor::instance ()->register_handler (ACE_STDIN, this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "Can't register signal handler\n"), 0); - + #endif /* ACE_WIN32 */ @@ -165,7 +165,7 @@ STDIN_Token::open (int argc, char *argv[]) this->display_menu (); #if (ACE_WIN32) - + #else ACE_Reactor::run_event_loop (); #endif /* ACE_WIN32 */ @@ -174,7 +174,7 @@ STDIN_Token::open (int argc, char *argv[]) return 0; } -int +int STDIN_Token::handle_input (ACE_HANDLE fd) { ACE_UNUSED_ARG (fd); @@ -189,8 +189,8 @@ STDIN_Token::handle_input (ACE_HANDLE fd) ACE_OS::printf ("Try again.\n"); return 0; } - - ACE_Token_Proxy *proxy = + + ACE_Token_Proxy *proxy = this->get_proxy (tid, token, type[0]); if (proxy == 0) @@ -255,7 +255,7 @@ STDIN_Token::display_menu (void) ACE_OS::printf ("<tid> <token> <type> <operation>\n"); } -int +int STDIN_Token::handle_exception (ACE_HANDLE fd) { ACE_UNUSED_ARG (fd); @@ -352,7 +352,11 @@ main (int argc, char* argv[]) return st.open (argc, argv); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Map_Entry<STDIN_Token::TID, ACE_Token_Collection *>; template class ACE_Map_Manager<STDIN_Token::TID, ACE_Token_Collection *, ACE_Null_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Map_Entry<STDIN_Token::TID, ACE_Token_Collection *> +#pragma instantiate ACE_Map_Manager<STDIN_Token::TID, ACE_Token_Collection *, ACE_Null_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/netsvcs/lib/Client_Logging_Handler.cpp b/netsvcs/lib/Client_Logging_Handler.cpp index 53f94af6c36..0135eb3a96d 100644 --- a/netsvcs/lib/Client_Logging_Handler.cpp +++ b/netsvcs/lib/Client_Logging_Handler.cpp @@ -21,9 +21,9 @@ ACE_Client_Logging_Handler::ACE_Client_Logging_Handler (const char rendezvous[]) else if (ACE_Reactor::instance ()->register_handler (this->message_fifo_.get_handle (), this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK) == -1) - ACE_ERROR ((LM_ERROR, "%n: %p\n", + ACE_ERROR ((LM_ERROR, "%n: %p\n", "register_handler (message_fifo)")); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "opened fifo at %s on handle %d\n", rendezvous, this->message_fifo_.get_handle ())); @@ -38,7 +38,7 @@ ACE_Client_Logging_Handler::handle_signal (int, siginfo_t *, ucontext_t *) return -1; } -int +int ACE_Client_Logging_Handler::open (void *) { ACE_INET_Addr server_addr; @@ -49,15 +49,15 @@ ACE_Client_Logging_Handler::open (void *) // reconnections. #if !defined (ACE_WIN32) if (ACE_Reactor::instance ()->register_handler (SIGPIPE, this) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n", "register_handler (SIGPIPE)"), -1); #endif /* ACE_WIN32 */ // Figure out what remote port we're really bound to. if (this->peer ().get_remote_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), -1); - - ACE_DEBUG ((LM_DEBUG, + + ACE_DEBUG ((LM_DEBUG, "starting up Client Logging Daemon, " "connected to port %d on handle %d\n", server_addr.get_port_number (), @@ -65,7 +65,7 @@ ACE_Client_Logging_Handler::open (void *) return 0; } -/* VIRTUAL */ ACE_HANDLE +/* VIRTUAL */ ACE_HANDLE ACE_Client_Logging_Handler::get_handle (void) const { ACE_TRACE ("ACE_Client_Logging_Handler::get_handle"); @@ -100,7 +100,7 @@ ACE_Client_Logging_Handler::handle_input (ACE_HANDLE handle) return 0; } -// Receive a logging record from an application send via a non-0 MSG_BAND... +// Receive a logging record from an application send via a non-0 MSG_BAND... // This just calls handle_input(). int @@ -111,17 +111,17 @@ ACE_Client_Logging_Handler::handle_exception (ACE_HANDLE handle) // Called when object is removed from the ACE_Reactor -int +int ACE_Client_Logging_Handler::close (u_long) { ACE_DEBUG ((LM_DEBUG, "shutting down!!!\n")); if (ACE_Reactor::instance ()->remove_handler - (this->message_fifo_.get_handle (), + (this->message_fifo_.get_handle (), ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK | ACE_Event_Handler::DONT_CALL) == -1) - ACE_ERROR ((LM_ERROR, "%n: %p\n", + ACE_ERROR ((LM_ERROR, "%n: %p\n", "remove_handler (message_fifo)")); - + this->message_fifo_.close (); this->destroy (); return 0; @@ -136,7 +136,7 @@ ACE_Client_Logging_Handler::handle_output (ACE_HANDLE) // Encodes the contents of log_record object using network byte-order // and sends it to the logging server. -int +int ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record) { if (this->logging_output_ == ACE_STDOUT) @@ -145,10 +145,10 @@ ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record) { long len = log_record.length (); long encoded_len = htonl (len); - + log_record.encode (); - if (this->peer ().send (4, &encoded_len, sizeof encoded_len, + if (this->peer ().send (4, &encoded_len, sizeof encoded_len, (char *) &log_record, len) == -1) // Switch over to logging to stdout for now. In the long // run, we'll need to queue up the message, try to @@ -179,18 +179,18 @@ protected: // = Scheduling hooks. virtual int suspend (void); virtual int resume (void); - + private: int parse_args (int argc, char *argv[]); // Parse svc.conf arguments. const char *server_host_; // Host where the logging server is located. - + u_short server_port_; // Port number where the logging server is listening for // connections. - + ACE_INET_Addr server_addr_; // Address of the logging server. @@ -202,7 +202,7 @@ private: // Pointer to the handler that does the work. }; -int +int ACE_Client_Logging_Connector::fini (void) { if (this->handler_ != 0) @@ -210,13 +210,13 @@ ACE_Client_Logging_Connector::fini (void) return 0; } -int +int ACE_Client_Logging_Connector::info (char **strp, size_t length) const { char buf[BUFSIZ]; - ACE_OS::sprintf (buf, "%d/%s %s", - this->server_addr_.get_port_number (), "tcp", + ACE_OS::sprintf (buf, "%d/%s %s", + this->server_addr_.get_port_number (), "tcp", "# client logging daemon\n"); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) @@ -226,7 +226,7 @@ ACE_Client_Logging_Connector::info (char **strp, size_t length) const return ACE_OS::strlen (buf); } -int +int ACE_Client_Logging_Connector::init (int argc, char *argv[]) { ACE_LOG_MSG->open ("Client Logging Service"); @@ -235,16 +235,16 @@ ACE_Client_Logging_Connector::init (int argc, char *argv[]) // options. this->parse_args (argc, argv); - ACE_NEW_RETURN (this->handler_, + ACE_NEW_RETURN (this->handler_, ACE_Client_Logging_Handler (this->rendezvous_key_), -1); // Establish connection with the server. - if (this->connect (this->handler_, - this->server_addr_, + if (this->connect (this->handler_, + this->server_addr_, ACE_Synch_Options::synch) == -1) { - ACE_ERROR ((LM_ERROR, "%p, using stdout\n", + ACE_ERROR ((LM_ERROR, "%p, using stdout\n", "can't connect to logging server")); this->handler_ = 0; } @@ -274,7 +274,7 @@ ACE_Client_Logging_Connector::parse_args (int argc, char *argv[]) this->server_port_ = ACE_OS::atoi (get_opt.optarg); break; default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%n:\n[-p server-port]\n%a", 1), -1); } @@ -284,14 +284,14 @@ ACE_Client_Logging_Connector::parse_args (int argc, char *argv[]) return 0; } -int +int ACE_Client_Logging_Connector::suspend (void) { // To be done... return 0; } -int +int ACE_Client_Logging_Connector::resume (void) { // To be done... @@ -304,10 +304,17 @@ ACE_Client_Logging_Connector::resume (void) ACE_SVC_FACTORY_DEFINE (ACE_Client_Logging_Connector) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<ACE_Client_Logging_Handler, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Tuple<ACE_Client_Logging_Handler>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<ACE_Client_Logging_Handler> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<ACE_Client_Logging_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<ACE_Client_Logging_Handler> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<ACE_Client_Logging_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Tuple<ACE_Client_Logging_Handler> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<ACE_Client_Logging_Handler> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<ACE_Client_Logging_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<ACE_Client_Logging_Handler> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/netsvcs/lib/Name_Handler.cpp b/netsvcs/lib/Name_Handler.cpp index 0cf4deb65fe..2a18ccb9a7c 100644 --- a/netsvcs/lib/Name_Handler.cpp +++ b/netsvcs/lib/Name_Handler.cpp @@ -31,7 +31,7 @@ ACE_Name_Acceptor::parse_args (int argc, char *argv[]) this->service_port_ = ACE_OS::atoi (get_opt.optarg); break; default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%n:\n[-p server-port]\n%a", 1), -1); } @@ -53,11 +53,11 @@ ACE_Name_Acceptor::init (int argc, char *argv[]) // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), - 0, 0, 0, + 0, 0, 0, &this->scheduling_strategy_, "Name Server", "ACE naming service") == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", - "acceptor::open failed", + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", + "acceptor::open failed", this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each <SVC_HANDLER> can handle this on its @@ -70,9 +70,9 @@ ACE_Name_Acceptor::init (int argc, char *argv[]) // Figure out what port we're really bound to. if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); - - ACE_DEBUG ((LM_DEBUG, - "starting up Name Server at port %d on handle %d\n", + + ACE_DEBUG ((LM_DEBUG, + "starting up Name Server at port %d on handle %d\n", server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; @@ -94,17 +94,17 @@ ACE_Name_Handler::ACE_Name_Handler (ACE_Thread_Manager *tm) // of client requests. this->op_table_[ACE_Name_Request::BIND] = &ACE_Name_Handler::bind; this->op_table_[ACE_Name_Request::REBIND] = &ACE_Name_Handler::rebind; - this->op_table_[ACE_Name_Request::RESOLVE] = &ACE_Name_Handler::resolve; - this->op_table_[ACE_Name_Request::UNBIND] = &ACE_Name_Handler::unbind; + this->op_table_[ACE_Name_Request::RESOLVE] = &ACE_Name_Handler::resolve; + this->op_table_[ACE_Name_Request::UNBIND] = &ACE_Name_Handler::unbind; this->op_table_[ACE_Name_Request::LIST_NAMES] = &ACE_Name_Handler::lists; this->op_table_[ACE_Name_Request::LIST_NAME_ENTRIES] = &ACE_Name_Handler::lists_entries; // Assign references to simplify subsequent code. - LIST_ENTRY &list_names_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_NAMES, + LIST_ENTRY &list_names_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_NAMES, ACE_Name_Request::LIST_OP_MASK)]; - LIST_ENTRY &list_values_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_VALUES, + LIST_ENTRY &list_values_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_VALUES, ACE_Name_Request::LIST_OP_MASK)]; - LIST_ENTRY &list_types_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_TYPES, + LIST_ENTRY &list_types_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_TYPES, ACE_Name_Request::LIST_OP_MASK)]; // Set up pointers to member functions for dispatching within the @@ -126,7 +126,7 @@ ACE_Name_Handler::ACE_Name_Handler (ACE_Thread_Manager *tm) // Activate this instance of the ACE_Name_Handler (called by the // ACE_Name_Acceptor). -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Name_Handler::open (void *) { ACE_TRACE ("ACE_Name_Handler::open"); @@ -143,7 +143,7 @@ ACE_Name_Handler::open (void *) // Create and send a reply to the client. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Name_Handler::send_reply (ACE_UINT32 status, ACE_UINT32 err) { ACE_TRACE ("ACE_Name_Handler::send_reply"); @@ -156,11 +156,11 @@ ACE_Name_Handler::send_reply (ACE_UINT32 status, ACE_UINT32 err) if (len == -1) return -1; - + ssize_t n = this->peer ().send (buf, len); if (n != len) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n, expected len = %d, actual len = %d", + ACE_ERROR_RETURN ((LM_ERROR, "%p\n, expected len = %d, actual len = %d", "send failed", len, n), -1); else return 0; @@ -172,12 +172,12 @@ ACE_Name_Handler::send_request (ACE_Name_Request &request) ACE_TRACE ("ACE_Name_Handler::send_request"); void *buffer; ssize_t length = request.encode (buffer); - + if (length == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "encode failed"), -1); - + // Transmit request via a blocking send. - + if (this->peer ().send_n (buffer, length) != length) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n failed"), -1); @@ -186,7 +186,7 @@ ACE_Name_Handler::send_request (ACE_Name_Request &request) // Give up waiting (e.g., when a timeout occurs or a client shuts down // unexpectedly). - + /* VIRTUAL */ int ACE_Name_Handler::abandon (void) { @@ -196,7 +196,7 @@ ACE_Name_Handler::abandon (void) } // Enable clients to limit the amount of time they'll wait - + /* VIRTUAL */ int ACE_Name_Handler::handle_timeout (const ACE_Time_Value &, const void *) { @@ -206,7 +206,7 @@ ACE_Name_Handler::handle_timeout (const ACE_Time_Value &, const void *) // Return the underlying ACE_HANDLE. -/* VIRTUAL */ ACE_HANDLE +/* VIRTUAL */ ACE_HANDLE ACE_Name_Handler::get_handle (void) const { ACE_TRACE ("ACE_Name_Handler::get_handle"); @@ -215,7 +215,7 @@ ACE_Name_Handler::get_handle (void) const // Dispatch the appropriate operation to handle the client request. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Name_Handler::dispatch (void) { ACE_TRACE ("ACE_Name_Handler::dispatch"); @@ -230,11 +230,11 @@ ACE_Name_Handler::dispatch (void) // list_type_entries. return (this->*op_table_[ACE_TABLE_MAP (index, ACE_Name_Request::OP_TABLE_MASK)]) (); } - + // Receive, frame, and decode the client's request. Note, this method // should use non-blocking I/O. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Name_Handler::recv_request (void) { ACE_TRACE ("ACE_Name_Handler::recv_request"); @@ -249,7 +249,7 @@ ACE_Name_Handler::recv_request (void) /* FALLTHROUGH */ ACE_DEBUG ((LM_DEBUG, "****************** recv_request returned -1\n")); default: - ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", + ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", "recv failed", n, sizeof (ACE_UINT32))); /* FALLTHROUGH */ case 0: @@ -271,14 +271,14 @@ ACE_Name_Handler::recv_request (void) // Receive the rest of the request message. // @@ beware of blocking read!!!. - n = this->peer ().recv ((void *) (((char *) &this->name_request_) - + sizeof (ACE_UINT32)), + n = this->peer ().recv ((void *) (((char *) &this->name_request_) + + sizeof (ACE_UINT32)), length - sizeof (ACE_UINT32)); // Subtract off the size of the part we skipped over... if (n != (length - (ssize_t) sizeof (ACE_UINT32))) { - ACE_ERROR ((LM_ERROR, "%p expected %d, got %d\n", + ACE_ERROR ((LM_ERROR, "%p expected %d, got %d\n", "invalid length", length, n)); return this->abandon (); } @@ -297,7 +297,7 @@ ACE_Name_Handler::recv_request (void) // Callback method invoked by the ACE_Reactor when events arrive from // the client. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Name_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_Name_Handler::handle_input"); @@ -335,13 +335,13 @@ ACE_Name_Handler::shared_bind (int rebind) if (rebind == 0) { ACE_DEBUG ((LM_DEBUG, "request for BIND \n")); - result = this->naming_context_->bind (a_name, a_value, + result = this->naming_context_->bind (a_name, a_value, this->name_request_.type ()); } else { ACE_DEBUG ((LM_DEBUG, "request for REBIND \n")); - result = this->naming_context_->rebind (a_name, a_value, + result = this->naming_context_->rebind (a_name, a_value, this->name_request_.type ()); if (result == 1) result = 0; @@ -363,7 +363,7 @@ ACE_Name_Handler::resolve (void) // pre-suppose success (indicated by type RESOLVE). ACE_WString avalue; - char *atype; + char *atype; if (this->naming_context_->resolve (a_name, avalue, atype) == 0) { ACE_Name_Request nrq (ACE_Name_Request::RESOLVE, @@ -373,8 +373,8 @@ ACE_Name_Handler::resolve (void) atype, ACE_OS::strlen (atype)); return this->send_request (nrq); } - - ACE_Name_Request nrq (ACE_Name_Request::BIND, NULL, 0, NULL, 0, NULL, 0); + + ACE_Name_Request nrq (ACE_Name_Request::BIND, NULL, 0, NULL, 0, NULL, 0); this->send_request (nrq); return 0; } @@ -391,7 +391,7 @@ ACE_Name_Handler::unbind (void) else return this->send_reply (ACE_Name_Reply::FAILURE); } -ACE_Name_Request +ACE_Name_Request ACE_Name_Handler::name_request (ACE_WString *one_name) { ACE_TRACE ("ACE_Name_Handler::name_request"); @@ -429,12 +429,12 @@ ACE_Name_Handler::lists (void) { ACE_TRACE ("ACE_Name_Handler::lists"); - ACE_PWSTRING_SET set; + ACE_PWSTRING_SET set; ACE_WString pattern (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_USHORT16)); // Get the index into the list table - int index = ACE_LIST_MAP (this->name_request_.msg_type (), + int index = ACE_LIST_MAP (this->name_request_.msg_type (), ACE_Name_Request::LIST_OP_MASK); // Print the message type @@ -452,7 +452,7 @@ ACE_Name_Handler::lists (void) else { ACE_WString *one_entry = 0; - + for (ACE_Unbounded_Set_Iterator<ACE_WString> set_iterator (set); set_iterator.next (one_entry) !=0; set_iterator.advance()) @@ -479,12 +479,12 @@ int ACE_Name_Handler::lists_entries (void) { ACE_TRACE ("ACE_Name_Handler::lists_entries"); - ACE_BINDING_SET set; + ACE_BINDING_SET set; ACE_WString pattern (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_USHORT16)); int (ACE_Naming_Context::*ptmf) (ACE_BINDING_SET &, const ACE_WString &); - + switch (this->name_request_.msg_type ()) { case ACE_Name_Request::LIST_NAME_ENTRIES: @@ -500,9 +500,9 @@ ACE_Name_Handler::lists_entries (void) ptmf = &ACE_Naming_Context::list_type_entries; break; default: - return -1; + return -1; } - + if ((this->naming_context_->*ptmf) (set, pattern) != 0) { // None found so send blank request back. @@ -514,7 +514,7 @@ ACE_Name_Handler::lists_entries (void) else { ACE_Name_Binding *one_entry = 0; - + for (ACE_Unbounded_Set_Iterator<ACE_Name_Binding> set_iterator (set); set_iterator.next (one_entry) !=0; set_iterator.advance()) @@ -530,9 +530,9 @@ ACE_Name_Handler::lists_entries (void) if (this->send_request (mynrq) == -1) return -1; } - + // send last message indicator - ACE_Name_Request nrq (ACE_Name_Request::MAX_ENUM, NULL, 0, NULL, 0, NULL, 0); + ACE_Name_Request nrq (ACE_Name_Request::MAX_ENUM, NULL, 0, NULL, 0, NULL, 0); if (this->send_request (nrq) == -1) return -1; @@ -550,7 +550,7 @@ ACE_Name_Handler::~ACE_Name_Handler (void) delete this->naming_context_; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Accept_Strategy<ACE_Name_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Acceptor<ACE_Name_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Concurrency_Strategy<ACE_Name_Handler>; @@ -558,4 +558,13 @@ template class ACE_Creation_Strategy<ACE_Name_Handler>; template class ACE_Schedule_All_Reactive_Strategy<ACE_Name_Handler>; template class ACE_Scheduling_Strategy<ACE_Name_Handler>; template class ACE_Strategy_Acceptor<ACE_Name_Handler, ACE_SOCK_ACCEPTOR>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Accept_Strategy<ACE_Name_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Acceptor<ACE_Name_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Concurrency_Strategy<ACE_Name_Handler> +#pragma instantiate ACE_Creation_Strategy<ACE_Name_Handler> +#pragma instantiate ACE_Schedule_All_Reactive_Strategy<ACE_Name_Handler> +#pragma instantiate ACE_Scheduling_Strategy<ACE_Name_Handler> +#pragma instantiate ACE_Strategy_Acceptor<ACE_Name_Handler, ACE_SOCK_ACCEPTOR> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/netsvcs/lib/Server_Logging_Handler.cpp b/netsvcs/lib/Server_Logging_Handler.cpp index e9cc86f1255..a40ac0bdc2d 100644 --- a/netsvcs/lib/Server_Logging_Handler.cpp +++ b/netsvcs/lib/Server_Logging_Handler.cpp @@ -15,7 +15,7 @@ ACE_SVC_FACTORY_DEFINE (ACE_Server_Logging_Acceptor) ACE_SVC_FACTORY_DEFINE (ACE_Thr_Server_Logging_Acceptor) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class Log_Message_Receiver_Impl<ACE_NULL_SYNCH>; template class Static_Log_Message_Receiver<ACE_NULL_SYNCH>; template class ACE_Acceptor<Null_Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR>; @@ -25,8 +25,8 @@ template class ACE_Creation_Strategy<Null_Synch_Logging_Handler_Static_Receiver> template class ACE_Schedule_All_Reactive_Strategy<Null_Synch_Logging_Handler_Static_Receiver>; template class ACE_Scheduling_Strategy<Null_Synch_Logging_Handler_Static_Receiver>; template class ACE_Strategy_Acceptor<Null_Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR>; -template class ACE_Server_Logging_Acceptor_T<Null_Synch_Logging_Handler_Static_Receiver, - Null_Synch_Static_Receiver, +template class ACE_Server_Logging_Acceptor_T<Null_Synch_Logging_Handler_Static_Receiver, + Null_Synch_Static_Receiver, ACE_Schedule_All_Reactive_Strategy<Null_Synch_Logging_Handler_Static_Receiver> >; template class ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, Null_Synch_Static_Receiver>; template class ACE_Server_Logging_Handler<Null_Synch_Static_Receiver>; @@ -70,23 +70,23 @@ template class ACE_Strategy_Acceptor<Synch_Thr_Logging_Handler_Static_Receiver, template class ACE_Strategy_Acceptor<Synch_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR>; template class ACE_Strategy_Acceptor<Synch_Thr_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR>; -template class ACE_Server_Logging_Acceptor_T<Synch_Logging_Handler_Static_Receiver, - Synch_Static_Receiver, +template class ACE_Server_Logging_Acceptor_T<Synch_Logging_Handler_Static_Receiver, + Synch_Static_Receiver, ACE_Schedule_All_Reactive_Strategy<Synch_Logging_Handler_Static_Receiver> >; -template class ACE_Server_Logging_Acceptor_T<Synch_Thr_Logging_Handler_Static_Receiver, - Synch_Static_Receiver, +template class ACE_Server_Logging_Acceptor_T<Synch_Thr_Logging_Handler_Static_Receiver, + Synch_Static_Receiver, ACE_Schedule_All_Threaded_Strategy<Synch_Thr_Logging_Handler_Static_Receiver> >; -template class ACE_Server_Logging_Acceptor_T<Synch_Logging_Handler_Receiver, - Synch_Receiver, +template class ACE_Server_Logging_Acceptor_T<Synch_Logging_Handler_Receiver, + Synch_Receiver, ACE_Schedule_All_Reactive_Strategy<Synch_Logging_Handler_Receiver> >; -template class ACE_Server_Logging_Acceptor_T<Synch_Thr_Logging_Handler_Receiver, - Synch_Receiver, +template class ACE_Server_Logging_Acceptor_T<Synch_Thr_Logging_Handler_Receiver, + Synch_Receiver, ACE_Schedule_All_Threaded_Strategy<Synch_Thr_Logging_Handler_Receiver> >; template class ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, Synch_Static_Receiver>; template class ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, Synch_Receiver>; - #if defined (ACE_HAS_THREADS) + #if defined (ACE_HAS_THREADS) template class ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_MT_SYNCH, Synch_Static_Receiver>; template class ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_MT_SYNCH, Synch_Receiver>; template class Log_Message_Receiver_Impl<ACE_MT_SYNCH>; @@ -98,7 +98,7 @@ template class ACE_Server_Logging_Handler<Synch_Receiver>; template class ACE_Thr_Server_Logging_Handler<Synch_Receiver>; template class ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_SYNCH>; - + #if defined (ACE_HAS_TLI) #if defined (ACE_HAS_THREADS) template class ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_NULL_SYNCH>; @@ -109,7 +109,102 @@ template class ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_SYNCH>; // That specialization is in TS_Server_Handler.cpp, so we don't need it // here. #endif /* ACE_HAS_TLI */ -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate Log_Message_Receiver_Impl<ACE_NULL_SYNCH> +#pragma instantiate Static_Log_Message_Receiver<ACE_NULL_SYNCH> +#pragma instantiate ACE_Acceptor<Null_Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Accept_Strategy<Null_Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Concurrency_Strategy<Null_Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Creation_Strategy<Null_Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Schedule_All_Reactive_Strategy<Null_Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Scheduling_Strategy<Null_Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Strategy_Acceptor<Null_Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Server_Logging_Acceptor_T<Null_Synch_Logging_Handler_Static_Receiver, \ + Null_Synch_Static_Receiver, \ + ACE_Schedule_All_Reactive_Strategy<Null_Synch_Logging_Handler_Static_Receiver> > +#pragma instantiate ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, Null_Synch_Static_Receiver> +#pragma instantiate ACE_Server_Logging_Handler<Null_Synch_Static_Receiver> + + +#pragma instantiate Static_Log_Message_Receiver<ACE_LOGGER_SYNCH> +#pragma instantiate Log_Message_Receiver<ACE_LOGGER_SYNCH> +#pragma instantiate ACE_Acceptor<Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Acceptor<Synch_Thr_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Acceptor<Synch_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Acceptor<Synch_Thr_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR> + +#pragma instantiate ACE_Accept_Strategy<Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Accept_Strategy<Synch_Thr_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Accept_Strategy<Synch_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Accept_Strategy<Synch_Thr_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR> + +#pragma instantiate ACE_Concurrency_Strategy<Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Concurrency_Strategy<Synch_Thr_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Concurrency_Strategy<Synch_Logging_Handler_Receiver> +#pragma instantiate ACE_Concurrency_Strategy<Synch_Thr_Logging_Handler_Receiver> + +#pragma instantiate ACE_Creation_Strategy<Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Creation_Strategy<Synch_Thr_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Creation_Strategy<Synch_Logging_Handler_Receiver> +#pragma instantiate ACE_Creation_Strategy<Synch_Thr_Logging_Handler_Receiver> + +#pragma instantiate ACE_Schedule_All_Reactive_Strategy<Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Schedule_All_Reactive_Strategy<Synch_Logging_Handler_Receiver> + +#pragma instantiate ACE_Schedule_All_Threaded_Strategy<Synch_Thr_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Schedule_All_Threaded_Strategy<Synch_Thr_Logging_Handler_Receiver> + +#pragma instantiate ACE_Scheduling_Strategy<Synch_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Scheduling_Strategy<Synch_Logging_Handler_Receiver> +#pragma instantiate ACE_Scheduling_Strategy<Synch_Thr_Logging_Handler_Static_Receiver> +#pragma instantiate ACE_Scheduling_Strategy<Synch_Thr_Logging_Handler_Receiver> + +#pragma instantiate ACE_Strategy_Acceptor<Synch_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Strategy_Acceptor<Synch_Thr_Logging_Handler_Static_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Strategy_Acceptor<Synch_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR> +#pragma instantiate ACE_Strategy_Acceptor<Synch_Thr_Logging_Handler_Receiver, LOGGING_PEER_ACCEPTOR> + +#pragma instantiate ACE_Server_Logging_Acceptor_T<Synch_Logging_Handler_Static_Receiver, \ + Synch_Static_Receiver, \ + ACE_Schedule_All_Reactive_Strategy<Synch_Logging_Handler_Static_Receiver> > +#pragma instantiate ACE_Server_Logging_Acceptor_T<Synch_Thr_Logging_Handler_Static_Receiver, \ + Synch_Static_Receiver, \ + ACE_Schedule_All_Threaded_Strategy<Synch_Thr_Logging_Handler_Static_Receiver> > +#pragma instantiate ACE_Server_Logging_Acceptor_T<Synch_Logging_Handler_Receiver, \ + Synch_Receiver, \ + ACE_Schedule_All_Reactive_Strategy<Synch_Logging_Handler_Receiver> > +#pragma instantiate ACE_Server_Logging_Acceptor_T<Synch_Thr_Logging_Handler_Receiver, \ + Synch_Receiver, \ + ACE_Schedule_All_Threaded_Strategy<Synch_Thr_Logging_Handler_Receiver> > + +#pragma instantiate ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, Synch_Static_Receiver> +#pragma instantiate ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, Synch_Receiver> + + #if defined (ACE_HAS_THREADS) + #pragma instantiate ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_MT_SYNCH, Synch_Static_Receiver> + #pragma instantiate ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_MT_SYNCH, Synch_Receiver> + #pragma instantiate Log_Message_Receiver_Impl<ACE_MT_SYNCH> + #endif /* ACE_HAS_THREADS */ + +#pragma instantiate ACE_Server_Logging_Handler<Synch_Static_Receiver> +#pragma instantiate ACE_Thr_Server_Logging_Handler<Synch_Static_Receiver> +#pragma instantiate ACE_Server_Logging_Handler<Synch_Receiver> +#pragma instantiate ACE_Thr_Server_Logging_Handler<Synch_Receiver> + +#pragma instantiate ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_SYNCH> + + #if defined (ACE_HAS_TLI) + #if defined (ACE_HAS_THREADS) + #pragma instantiate ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_NULL_SYNCH> + #endif /* ACE_HAS_THREADS */ + // else if ! ACE_HAS_TLI, LOGGING_PEER_STREAM is ACE_SOCK_STREAM, + // and the specialization would be + // #pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> + // That specialization is in TS_Server_Handler.cpp, so we don't need it + // here. + #endif /* ACE_HAS_TLI */ +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_SERVER_LOGGING_HANDLERT_C */ diff --git a/netsvcs/lib/TS_Clerk_Handler.cpp b/netsvcs/lib/TS_Clerk_Handler.cpp index 272c30811ac..8c248f0c7b6 100644 --- a/netsvcs/lib/TS_Clerk_Handler.cpp +++ b/netsvcs/lib/TS_Clerk_Handler.cpp @@ -55,7 +55,7 @@ ACE_TS_Clerk_Handler::timeout (void) ACE_TRACE ("ACE_TS_Clerk_Handler::timeout"); int old_timeout = this->timeout_; this->timeout_ *= 2; - + if (this->timeout_ > this->max_timeout_) this->timeout_ = this->max_timeout_; @@ -87,7 +87,7 @@ ACE_TS_Clerk_Handler::max_timeout (void) return this->max_timeout_; } -int +int ACE_TS_Clerk_Handler::open (void *) { ACE_TRACE ("ACE_TS_Clerk_Handler::open"); @@ -100,22 +100,22 @@ ACE_TS_Clerk_Handler::open (void *) // reconnections. #if !defined (ACE_WIN32) if (ACE_Reactor::instance ()->register_handler (SIGPIPE, this) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n", "register_handler (SIGPIPE)"), -1); #endif // Register ourselves with the reactor to receive input - if (ACE_Reactor::instance ()->register_handler (this->get_handle (), + if (ACE_Reactor::instance ()->register_handler (this->get_handle (), this, - ACE_Event_Handler::READ_MASK | + ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK) == -1) ACE_ERROR ((LM_ERROR, "%n: %p\n", "register_handler (this)")); // Figure out what remote port we're really bound to. else if (this->peer ().get_remote_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), -1); - - ACE_DEBUG ((LM_DEBUG, + + ACE_DEBUG ((LM_DEBUG, "TS Clerk Daemon connected to port %d on handle %d\n", server_addr.get_port_number (), this->peer ().get_handle ())); @@ -123,14 +123,14 @@ ACE_TS_Clerk_Handler::open (void *) return 0; } -ACE_HANDLE +ACE_HANDLE ACE_TS_Clerk_Handler::get_handle (void) const { ACE_TRACE ("ACE_TS_Clerk_Handler::get_handle"); return this->peer().get_handle (); } -int +int ACE_TS_Clerk_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask mask) { @@ -149,14 +149,14 @@ ACE_TS_Clerk_Handler::reinitiate_connection (void) // Skip over deactivated descriptors. // Set state to connecting so that we don't try to send anything - // using this handler + // using this handler this->state (ACE_TS_Clerk_Handler::CONNECTING); if (this->get_handle () != ACE_INVALID_HANDLE) { ACE_DEBUG ((LM_DEBUG, "(%t) Scheduling reinitiation of connection\n")); // Reschedule ourselves to try and connect again. - if (ACE_Reactor::instance ()->schedule_timer (this, 0, + if (ACE_Reactor::instance ()->schedule_timer (this, 0, this->timeout ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "schedule_timer"), -1); } @@ -198,12 +198,12 @@ ACE_TS_Clerk_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_timeout"); - ACE_DEBUG ((LM_DEBUG, - "(%t) attempting to reconnect to server with timeout = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) attempting to reconnect to server with timeout = %d\n", this->timeout_)); // Close down peer to reclaim descriptor if need be. Note this is - // necessary to reconnect. + // necessary to reconnect. this->peer ().close (); return this->processor_->initiate_connection (this, ACE_Synch_Options::asynch); @@ -238,12 +238,12 @@ ACE_TS_Clerk_Handler::recv_reply (ACE_Time_Request &reply) switch (n) { case -1: - // FALLTHROUGH + // FALLTHROUGH ACE_DEBUG ((LM_DEBUG, "****************** recv_reply returned -1\n")); default: ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", "recv failed", n, bytes_expected)); - // FALLTHROUGH + // FALLTHROUGH case 0: // We've shutdown unexpectedly return -1; @@ -252,7 +252,7 @@ ACE_TS_Clerk_Handler::recv_reply (ACE_Time_Request &reply) } else if (reply.decode () == -1) // Decode the request into host byte order. ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "decode failed"), -1); - return 0; + return 0; } @@ -265,17 +265,17 @@ ACE_TS_Clerk_Handler::send_request (ACE_UINT32 sequence_num, ACE_Time_Info &time // Update current sequence number this->cur_sequence_num_ = sequence_num; - + // First update the current time info. time_info.delta_time_ = this->time_info_.delta_time_; time_info.sequence_num_ = this->time_info_.sequence_num_; // Now prepare a new time update request ACE_Time_Request request (ACE_Time_Request::TIME_UPDATE, 0, 0); - + if ((length = request.encode (buffer)) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "encode failed"), -1); - + // Compute start time of sending request (needed to compute // roundtrip delay) this->start_time_ = ACE_OS::time (0); @@ -284,7 +284,7 @@ ACE_TS_Clerk_Handler::send_request (ACE_UINT32 sequence_num, ACE_Time_Info &time if (this->peer ().send_n (buffer, length) != length) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n failed"), -1); - return 0; + return 0; } ACE_TS_Clerk_Processor::ACE_TS_Clerk_Processor () @@ -306,7 +306,7 @@ ACE_TS_Clerk_Processor::alloc (void) { // Allocate the space out of shared memory for the system time entry void *temp = this->shmem_->malloc (sizeof (this->system_time_)); - + // Give it a name binding this->shmem_->bind (ACE_DEFAULT_TIME_SERVER_STR, temp); @@ -330,7 +330,7 @@ ACE_TS_Clerk_Processor::handle_timeout (const ACE_Time_Value &, return this->update_time (); } -int +int ACE_TS_Clerk_Processor::update_time () { ACE_TRACE ("ACE_TS_Clerk_Processor::update_time"); @@ -345,11 +345,11 @@ ACE_TS_Clerk_Processor::update_time () // Call send_request() on all handlers ACE_TS_Clerk_Handler **handler = 0; - + for (HANDLER_SET_ITERATOR set_iterator (this->handler_set_); set_iterator.next (handler) != 0; set_iterator.advance ()) - { + { if ((*handler)->state () == ACE_TS_Clerk_Handler::ESTABLISHED) { if ((*handler)->send_request (this->cur_sequence_num_, time_info) == -1) @@ -370,8 +370,8 @@ ACE_TS_Clerk_Processor::update_time () // Note that we are keeping two things in shared memory: the delta // time (difference between our system clock and the local clock), // and the last local time - if (count > 0) - { + if (count > 0) + { // At least one server is out there *(this->system_time_.delta_time_) = total_delta/count; } @@ -390,7 +390,7 @@ ACE_TS_Clerk_Processor::update_time () } -int +int ACE_TS_Clerk_Processor::fini (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::fini"); @@ -405,7 +405,7 @@ ACE_TS_Clerk_Processor::fini (void) for (HANDLER_SET_ITERATOR set_iterator (this->handler_set_); set_iterator.next (handler) != 0; set_iterator.advance ()) - { + { if ((*handler)->state () != ACE_TS_Clerk_Handler::IDLE) // Mark state as DISCONNECTING so we don't try to reconnect... (*handler)->state (ACE_TS_Clerk_Handler::DISCONNECTING); @@ -418,18 +418,18 @@ ACE_TS_Clerk_Processor::fini (void) this->shmem_->remove (); ACE_Connector <ACE_TS_Clerk_Handler, ACE_SOCK_CONNECTOR>::fini (); - + return 0; } -int +int ACE_TS_Clerk_Processor::info (char **, size_t) const { ACE_TRACE ("ACE_TS_Clerk_Processor::info"); return 0; } -int +int ACE_TS_Clerk_Processor::init (int argc, char *argv[]) { ACE_TRACE ("ACE_TS_Clerk_Processor::init"); @@ -445,22 +445,22 @@ ACE_TS_Clerk_Processor::init (int argc, char *argv[]) ACE_UNUSED_ARG (sig); #endif /* ACE_WIN32 */ - ACE_Synch_Options &synch_options = this->blocking_semantics_ == 0 + ACE_Synch_Options &synch_options = this->blocking_semantics_ == 0 ? ACE_Synch_Options::asynch : ACE_Synch_Options::synch; // Now set up connections to all servers ACE_TS_Clerk_Handler **handler = 0; - + for (HANDLER_SET_ITERATOR set_iterator (this->handler_set_); set_iterator.next (handler) != 0; set_iterator.advance ()) - { + { this->initiate_connection (*handler, synch_options); } // Now set up timer to receive updates from server // set the timer to go off after timeout value - this->timer_id_ = ACE_Reactor::instance ()->schedule_timer (this, - NULL, + this->timer_id_ = ACE_Reactor::instance ()->schedule_timer (this, + NULL, ACE_Time_Value (this->timeout_), ACE_Time_Value (this->timeout_)); return 0; @@ -478,7 +478,7 @@ ACE_TS_Clerk_Processor::initiate_connection (ACE_TS_Clerk_Handler *handler, handler->state (ACE_TS_Clerk_Handler::IDLE); if (handler->remote_addr ().addr_to_string (buf, sizeof buf) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "can't obtain peer's address"), -1); // Establish connection with the server. @@ -494,12 +494,12 @@ ACE_TS_Clerk_Processor::initiate_connection (ACE_TS_Clerk_Handler *handler, // Reschedule ourselves to try and connect again. if (synch_options[ACE_Synch_Options::USE_REACTOR]) { - if (ACE_Reactor::instance ()->schedule_timer (handler, - 0, + if (ACE_Reactor::instance ()->schedule_timer (handler, + 0, handler->timeout ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "schedule_timer"), -1); } - else + else // Failures on synchronous connects are reported as errors // so that the caller can decide how to proceed. return -1; @@ -507,16 +507,16 @@ ACE_TS_Clerk_Processor::initiate_connection (ACE_TS_Clerk_Handler *handler, else { handler->state (ACE_TS_Clerk_Handler::CONNECTING); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) in the process of connecting %s to %s\n", - synch_options[ACE_Synch_Options::USE_REACTOR] + synch_options[ACE_Synch_Options::USE_REACTOR] ? "asynchronously" : "synchronously", buf)); } } - else + else { handler->state (ACE_TS_Clerk_Handler::ESTABLISHED); - ACE_DEBUG ((LM_DEBUG, "(%t) connected to %s on %d\n", + ACE_DEBUG ((LM_DEBUG, "(%t) connected to %s on %d\n", buf, handler->get_handle ())); } return 0; @@ -532,7 +532,7 @@ ACE_TS_Clerk_Processor::parse_args (int argc, char *argv[]) // Create a default entry ACE_OS::sprintf (server_host, "%s:%d", - ACE_DEFAULT_SERVER_HOST, + ACE_DEFAULT_SERVER_HOST, ACE_DEFAULT_LOGGING_SERVER_PORT); ACE_Get_Opt get_opt (argc, argv, "h:t:p:b", 0); @@ -549,7 +549,7 @@ ACE_TS_Clerk_Processor::parse_args (int argc, char *argv[]) ACE_NEW_RETURN (handler, ACE_TS_Clerk_Handler (this, server_addr), -1); - + // Cache the handler this->handler_set_.insert (handler); break; @@ -568,7 +568,7 @@ ACE_TS_Clerk_Processor::parse_args (int argc, char *argv[]) this->blocking_semantics_ = 1; break; default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%n:\n[-h hostname:port] [-t timeout] [-p poolname]\n%a", 1), -1); } @@ -576,14 +576,14 @@ ACE_TS_Clerk_Processor::parse_args (int argc, char *argv[]) return 0; } -int +int ACE_TS_Clerk_Processor::suspend (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::suspend"); return 0; } -int +int ACE_TS_Clerk_Processor::resume (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::resume"); @@ -595,7 +595,7 @@ ACE_TS_Clerk_Processor::resume (void) ACE_SVC_FACTORY_DEFINE (ACE_TS_Clerk_Processor) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<ACE_TS_Clerk_Handler, ACE_SOCK_CONNECTOR>; template class ACE_Node<ACE_TS_Clerk_Handler *>; template class ACE_Svc_Tuple<ACE_TS_Clerk_Handler>; @@ -604,4 +604,14 @@ template class ACE_Unbounded_Set_Iterator<ACE_TS_Clerk_Handler *>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<ACE_TS_Clerk_Handler> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<ACE_TS_Clerk_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<ACE_TS_Clerk_Handler> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<ACE_TS_Clerk_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Node<ACE_TS_Clerk_Handler *> +#pragma instantiate ACE_Svc_Tuple<ACE_TS_Clerk_Handler> +#pragma instantiate ACE_Unbounded_Set<ACE_TS_Clerk_Handler *> +#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_TS_Clerk_Handler *> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<ACE_TS_Clerk_Handler> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<ACE_TS_Clerk_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<ACE_TS_Clerk_Handler> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/netsvcs/lib/TS_Server_Handler.cpp b/netsvcs/lib/TS_Server_Handler.cpp index 95736e085c7..ad35c939665 100644 --- a/netsvcs/lib/TS_Server_Handler.cpp +++ b/netsvcs/lib/TS_Server_Handler.cpp @@ -26,7 +26,7 @@ ACE_TS_Server_Acceptor::parse_args (int argc, char *argv[]) this->service_port_ = ACE_OS::atoi (get_opt.optarg); break; default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%n:\n[-p server-port]\n%a", 1), -1); } @@ -47,11 +47,11 @@ ACE_TS_Server_Acceptor::init (int argc, char *argv[]) // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), - 0, 0, 0, + 0, 0, 0, &this->scheduling_strategy_, "Time Server", "ACE time service") == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", - "acceptor::open failed", + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", + "acceptor::open failed", this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each <SVC_HANDLER> can handle this on its @@ -64,9 +64,9 @@ ACE_TS_Server_Acceptor::init (int argc, char *argv[]) // Figure out what port we're really bound to. if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); - - ACE_DEBUG ((LM_DEBUG, - "starting up Time Server at port %d on handle %d\n", + + ACE_DEBUG ((LM_DEBUG, + "starting up Time Server at port %d on handle %d\n", server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; @@ -87,7 +87,7 @@ ACE_TS_Server_Handler::ACE_TS_Server_Handler (ACE_Thread_Manager *tm) // Activate this instance of the ACE_TS_Server_Handler (called by the // ACE_TS_Server_Acceptor). -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_TS_Server_Handler::open (void *) { ACE_TRACE ("ACE_TS_Server_Handler::open"); @@ -113,12 +113,12 @@ ACE_TS_Server_Handler::send_request (ACE_Time_Request &request) ACE_TRACE ("ACE_TS_Server_Handler::send_request"); void *buffer; ssize_t length = request.encode (buffer); - + if (length == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "encode failed"), -1); - + // Transmit request via a blocking send. - + if (this->peer ().send_n (buffer, length) != length) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n failed"), -1); @@ -127,14 +127,14 @@ ACE_TS_Server_Handler::send_request (ACE_Time_Request &request) // Give up waiting (e.g., when a timeout occurs or a client shuts down // unexpectedly). - + /* VIRTUAL */ int ACE_TS_Server_Handler::abandon (void) { ACE_TRACE ("ACE_TS_Server_Handler::abandon"); // Note we are using the time field to report the errno in case of - // failure. + // failure. ACE_Time_Request rq (ACE_Time_Request::FAILURE, errno); return this->send_request (rq); } @@ -149,7 +149,7 @@ ACE_TS_Server_Handler::handle_timeout (const ACE_Time_Value &, const void *) // Return the underlying ACE_HANDLE. -/* VIRTUAL */ ACE_HANDLE +/* VIRTUAL */ ACE_HANDLE ACE_TS_Server_Handler::get_handle (void) const { ACE_TRACE ("ACE_TS_Server_Handler::get_handle"); @@ -158,7 +158,7 @@ ACE_TS_Server_Handler::get_handle (void) const // Dispatch the appropriate operation to handle the client request. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_TS_Server_Handler::dispatch (void) { ACE_TRACE ("ACE_TS_Server_Handler::dispatch"); @@ -167,11 +167,11 @@ ACE_TS_Server_Handler::dispatch (void) ACE_Time_Request rq (ACE_Time_Request::TIME_UPDATE, t); return this->send_request (rq); } - + // Receive, frame, and decode the client's request. Note, this method // should use non-blocking I/O. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_TS_Server_Handler::recv_request (void) { ACE_TRACE ("ACE_TS_Server_Handler::recv_request"); @@ -188,7 +188,7 @@ ACE_TS_Server_Handler::recv_request (void) /* FALLTHROUGH */ ACE_DEBUG ((LM_DEBUG, "****************** recv_request returned -1\n")); default: - ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", + ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", "recv failed", n, bytes_expected)); /* FALLTHROUGH */ case 0: @@ -213,7 +213,7 @@ ACE_TS_Server_Handler::recv_request (void) // Callback method invoked by the ACE_Reactor when events arrive from // the client. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_TS_Server_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_TS_Server_Handler::handle_input"); @@ -231,7 +231,7 @@ ACE_TS_Server_Handler::~ACE_TS_Server_Handler (void) this->get_handle ())); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Accept_Strategy<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Concurrency_Strategy<ACE_TS_Server_Handler>; @@ -240,4 +240,14 @@ template class ACE_Schedule_All_Reactive_Strategy<ACE_TS_Server_Handler>; template class ACE_Scheduling_Strategy<ACE_TS_Server_Handler>; template class ACE_Strategy_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Accept_Strategy<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Concurrency_Strategy<ACE_TS_Server_Handler> +#pragma instantiate ACE_Creation_Strategy<ACE_TS_Server_Handler> +#pragma instantiate ACE_Schedule_All_Reactive_Strategy<ACE_TS_Server_Handler> +#pragma instantiate ACE_Scheduling_Strategy<ACE_TS_Server_Handler> +#pragma instantiate ACE_Strategy_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/netsvcs/lib/Token_Handler.cpp b/netsvcs/lib/Token_Handler.cpp index 0a520bc6afa..1c13a1dd4a1 100644 --- a/netsvcs/lib/Token_Handler.cpp +++ b/netsvcs/lib/Token_Handler.cpp @@ -26,7 +26,7 @@ ACE_Token_Acceptor::parse_args (int argc, char *argv[]) this->service_port_ = ACE_OS::atoi (get_opt.optarg); break; default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%n:\n[-p server-port]\n%a", 1), -1); } @@ -48,11 +48,11 @@ ACE_Token_Acceptor::init (int argc, char *argv[]) // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), - 0, 0, 0, + 0, 0, 0, &this->scheduling_strategy_, "Token Server", "ACE token service") == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", - "acceptor::open failed", + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", + "acceptor::open failed", this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each <SVC_HANDLER> can handle this on its @@ -64,9 +64,9 @@ ACE_Token_Acceptor::init (int argc, char *argv[]) if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), -1); - - ACE_DEBUG ((LM_DEBUG, - "starting up Token Server at port %d on handle %d\n", + + ACE_DEBUG ((LM_DEBUG, + "starting up Token Server at port %d on handle %d\n", server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; @@ -90,7 +90,7 @@ ACE_Token_Handler::ACE_Token_Handler (ACE_Thread_Manager *tm) // Create and send a reply to the client. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::send_reply (ACE_UINT32 err) { ACE_TRACE ("ACE_Token_Handler::send_reply"); @@ -105,7 +105,7 @@ ACE_Token_Handler::send_reply (ACE_UINT32 err) n = this->peer ().send (buf, len); if (n != (ssize_t) len) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "%p, expected len = %d, actual len = %d\n", "send failed", len, n), -1); else @@ -114,11 +114,11 @@ ACE_Token_Handler::send_reply (ACE_UINT32 err) // Acquire the token. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::acquire (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::acquire"); - ACE_DEBUG ((LM_DEBUG, "in acquire for client id = %s\n", + ACE_DEBUG ((LM_DEBUG, "in acquire for client id = %s\n", proxy->client_id ())); // @@ add notify in token request reply @@ -137,7 +137,7 @@ ACE_Token_Handler::acquire (ACE_Token_Proxy *proxy) return this->send_reply (EWOULDBLOCK); // schedule a timer - this->timeout_id_ = this->reactor ()->schedule_timer + this->timeout_id_ = this->reactor ()->schedule_timer (this, (void *) proxy, request_options_.timeout ()); if (timeout_id_ == -1) { @@ -155,7 +155,7 @@ ACE_Token_Handler::acquire (ACE_Token_Proxy *proxy) // Try to acquire the token. Never block. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::try_acquire (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::try_acquire"); @@ -173,12 +173,12 @@ ACE_Token_Handler::try_acquire (ACE_Token_Proxy *proxy) // Release the token and allow the next client that is waiting to // proceed. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::release (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::release"); - ACE_DEBUG ((LM_DEBUG, - "in release for client id = %s\n", + ACE_DEBUG ((LM_DEBUG, + "in release for client id = %s\n", proxy->client_id ())); if (proxy->release (ACE_Synch_Options::asynch) == -1) @@ -191,22 +191,22 @@ ACE_Token_Handler::release (ACE_Token_Proxy *proxy) this->reactor ()->cancel_timer (timeout_id_); this->timeout_id_ = 0; } - + return this->send_reply (ACE_Token_Reply::SUCCESS); } // Yield the token if any clients are waiting, otherwise keep the // token. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::renew (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::renew"); - ACE_DEBUG ((LM_DEBUG, "in renew for client id = %s\n", + ACE_DEBUG ((LM_DEBUG, "in renew for client id = %s\n", proxy->client_id ())); - if (proxy->renew (token_request_.requeue_position (), + if (proxy->renew (token_request_.requeue_position (), ACE_Synch_Options::asynch) == -1) { int result = ACE_LOG_MSG->errnum (); @@ -217,7 +217,7 @@ ACE_Token_Handler::renew (ACE_Token_Proxy *proxy) // acquire would block if (request_options_[ACE_Synch_Options::USE_TIMEOUT] == 1) { - this->timeout_id_ = this->reactor ()->schedule_timer + this->timeout_id_ = this->reactor ()->schedule_timer (this, 0, request_options_.timeout ()); if (timeout_id_ == -1) { @@ -234,11 +234,11 @@ ACE_Token_Handler::renew (ACE_Token_Proxy *proxy) return this->send_reply (ACE_Token_Reply::SUCCESS); } -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::remove (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::remove"); - ACE_DEBUG ((LM_DEBUG, "in remove for client id = %s\n", + ACE_DEBUG ((LM_DEBUG, "in remove for client id = %s\n", proxy->client_id ())); ACE_ERROR ((LM_ERROR, "sorry: ACE_Token_Handler::remove() is not implemented")); @@ -248,8 +248,8 @@ ACE_Token_Handler::remove (ACE_Token_Proxy *proxy) // Enable clients to limit the amount of time they'll wait for a // token. -/* VIRTUAL */ int -ACE_Token_Handler::handle_timeout (const ACE_Time_Value &, +/* VIRTUAL */ int +ACE_Token_Handler::handle_timeout (const ACE_Time_Value &, const void *tp) { ACE_TRACE ("ACE_Token_Handler::handle_timeout"); @@ -264,7 +264,7 @@ ACE_Token_Handler::handle_timeout (const ACE_Time_Value &, ACE_Token_Proxy *proxy = (ACE_Token_Proxy *) tp; - ACE_DEBUG ((LM_DEBUG, "in handle_timeout for client id = %s\n", + ACE_DEBUG ((LM_DEBUG, "in handle_timeout for client id = %s\n", proxy->client_id ())); // Remove ourselves from the waiter list. @@ -314,12 +314,12 @@ ACE_Token_Handler::create_proxy (void) ACE_TRACE ("ACE_Token_Handler::new_proxy"); ACE_Token_Proxy *proxy; - + switch (token_request_.token_type ()) { case ACE_Tokens::RWLOCK: if (token_request_.proxy_type () == ACE_RW_Token::READER) - ACE_NEW_RETURN (proxy, + ACE_NEW_RETURN (proxy, ACE_TS_RLock (token_request_.token_name (), this), 0); else @@ -373,11 +373,11 @@ ACE_Token_Handler::dispatch (void) /* NOTREACHED */ } } - + // Receive, frame, and decode the client's request. // Note, this method should use non-blocking I/O. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::recv_request (void) { ACE_TRACE ("ACE_Token_Handler::recv_request"); @@ -386,7 +386,7 @@ ACE_Token_Handler::recv_request (void) // Read the first 4 bytes to get the length of the message // This implementation assumes that the first 4 bytes are // the length of the message. - n = this->peer ().recv ((void *) &this->token_request_, + n = this->peer ().recv ((void *) &this->token_request_, sizeof (ACE_UINT32)); switch (n) @@ -394,7 +394,7 @@ ACE_Token_Handler::recv_request (void) case -1: /* FALLTHROUGH */ default: - ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", + ACE_ERROR ((LM_ERROR, "%p got %d bytes, expected %d bytes\n", "recv failed", n, sizeof (ACE_UINT32))); /* FALLTHROUGH */ case 0: @@ -417,13 +417,13 @@ ACE_Token_Handler::recv_request (void) // Receive the rest of the request message. // @@ beware of blocking read!!!. n = this->peer ().recv ((void *) (((char *) &this->token_request_) - + sizeof (ACE_UINT32)), + + sizeof (ACE_UINT32)), length - sizeof (ACE_UINT32)); - + // Subtract off the size of the part we skipped over... if (n != (length - (ssize_t) sizeof (ACE_UINT32))) { - ACE_ERROR ((LM_ERROR, "%p expected %d, got %d\n", + ACE_ERROR ((LM_ERROR, "%p expected %d, got %d\n", "invalid length", length, n)); return this->abandon (1); } @@ -442,10 +442,10 @@ ACE_Token_Handler::recv_request (void) return 0; } -// Callback method invoked by the ACE_Reactor when +// Callback method invoked by the ACE_Reactor when // events arrive from the client. -/* VIRTUAL */ int +/* VIRTUAL */ int ACE_Token_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_Token_Handler::handle_input"); @@ -476,7 +476,7 @@ ACE_Token_Handler::token_acquired (ACE_TPQ_Entry *) this->reactor ()->cancel_timer (this->timeout_id_); this->timeout_id_ = 0; } - + this->send_reply (ACE_Token_Reply::SUCCESS); } @@ -494,7 +494,7 @@ ACE_Token_Handler::abandon (int send_error) // @@ release all tokens collection_.release (); - + if (send_error) return this->send_reply (EIO); else @@ -521,7 +521,7 @@ ACE_TS_Mutex::ACE_TS_Mutex (const ACE_TS_Mutex &m) this->open (m.name (), m.ignore_deadlock_, m.debug_); } -void +void ACE_TS_Mutex::sleep_hook (void) { ACE_TRACE ("ACE_TS_Mutex::sleep_hook"); @@ -565,7 +565,7 @@ ACE_TS_RLock::ACE_TS_RLock (const ACE_TS_RLock &r) this->open (r.name (), r.ignore_deadlock_, r.debug_); } -void +void ACE_TS_RLock::sleep_hook (void) { ACE_TRACE ("ACE_TS_RLock::sleep_hook"); @@ -587,7 +587,7 @@ ACE_TS_RLock::clone (void) const { ACE_TRACE ("ACE_TS_RLock::clone"); ACE_Token_Proxy *temp; - + ACE_NEW_RETURN (temp, ACE_TS_RLock (*this), 0); return temp; } @@ -610,7 +610,7 @@ ACE_TS_WLock::ACE_TS_WLock (const ACE_TS_WLock &w) this->open (w.name (), w.ignore_deadlock_, w.debug_); } -void +void ACE_TS_WLock::sleep_hook (void) { ACE_TRACE ("ACE_TS_WLock::sleep_hook"); @@ -632,12 +632,12 @@ ACE_TS_WLock::clone (void) const { ACE_TRACE ("ACE_TS_WLock::clone"); ACE_Token_Proxy *temp; - + ACE_NEW_RETURN (temp, ACE_TS_WLock (*this), 0); return temp; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<ACE_Token_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Accept_Strategy<ACE_Token_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Concurrency_Strategy<ACE_Token_Handler>; @@ -645,4 +645,13 @@ template class ACE_Creation_Strategy<ACE_Token_Handler>; template class ACE_Schedule_All_Reactive_Strategy<ACE_Token_Handler>; template class ACE_Scheduling_Strategy<ACE_Token_Handler>; template class ACE_Strategy_Acceptor<ACE_Token_Handler, ACE_SOCK_ACCEPTOR>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<ACE_Token_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Accept_Strategy<ACE_Token_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Concurrency_Strategy<ACE_Token_Handler> +#pragma instantiate ACE_Creation_Strategy<ACE_Token_Handler> +#pragma instantiate ACE_Schedule_All_Reactive_Strategy<ACE_Token_Handler> +#pragma instantiate ACE_Scheduling_Strategy<ACE_Token_Handler> +#pragma instantiate ACE_Strategy_Acceptor<ACE_Token_Handler, ACE_SOCK_ACCEPTOR> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/performance-tests/Misc/test_singleton.cpp b/performance-tests/Misc/test_singleton.cpp index db19735d9b9..f0f18644347 100644 --- a/performance-tests/Misc/test_singleton.cpp +++ b/performance-tests/Misc/test_singleton.cpp @@ -6,7 +6,7 @@ // call. In addition, we compare the performance of using the // ACE_Singleton (which encapsulates the Double-Check Locking pattern) // vs. hand-coding the pattern. -// +// // Here's the output from running this test on our SPARCstation 20, model 712s. // // ./test_singleton 1000000 @@ -125,7 +125,7 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); - ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); // Test the hand-coded Singleton performance (which uses @@ -144,7 +144,7 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); - ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); // Test the Mutex_Singleton implementation (which does not use @@ -163,18 +163,21 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); - ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<DC_Singleton, ACE_Thread_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Singleton<DC_Singleton, ACE_Thread_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/performance-tests/Synch-Benchmarks/Benchmark.cpp b/performance-tests/Synch-Benchmarks/Benchmark.cpp index e95cf180bd0..a0558e9b2c3 100644 --- a/performance-tests/Synch-Benchmarks/Benchmark.cpp +++ b/performance-tests/Synch-Benchmarks/Benchmark.cpp @@ -9,13 +9,13 @@ ACE_Svc_Export int synch_count; int buffer; -// Initialize the static variables. +// Initialize the static variables. /* static */ sig_atomic_t Benchmark::done_ = 0; sig_atomic_t Benchmark::done (void) -{ +{ return Benchmark::done_; } @@ -32,8 +32,8 @@ Benchmark::thr_id (void) void Benchmark::done (sig_atomic_t d) -{ - Benchmark::done_ = d; +{ + Benchmark::done_ = d; } int @@ -88,8 +88,11 @@ Thr_ID::thr_id (int i) this->thr_id_ = i; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_TSS<Thr_ID>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_TSS<Thr_ID> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ #endif /* ACE_HAS_THREADS */ diff --git a/performance-tests/Synch-Benchmarks/Options.cpp b/performance-tests/Synch-Benchmarks/Options.cpp index 9abbd4d48f8..07baea92b1e 100644 --- a/performance-tests/Synch-Benchmarks/Options.cpp +++ b/performance-tests/Synch-Benchmarks/Options.cpp @@ -179,7 +179,7 @@ Options::parse_args (int argc, char *argv[]) "\t[-B] (THR_BOUND)\n" "\t[-c] + number of logical connections\n" "\t[-c] - number of physical connections\n" - "\t[-C] (enable checksumming)\n" + "\t[-C] (enable checksumming)\n" "\t[-d] (enable debugging)\n" "\t[-D] (THR_DETACHED)\n" "\t[-e] (eager exit)\n" @@ -189,9 +189,9 @@ Options::parse_args (int argc, char *argv[]) "\t[-i] number of test iterations [%d]\n" "\t[-L] low water mark\n" "\t[-m] mapped file\n" - "\t[-M] message size\n" - "\t[-n] number of LWPs\n" - "\t[-N] (THR_NEW_LWP)\n" + "\t[-M] message size\n" + "\t[-n] number of LWPs\n" + "\t[-N] (THR_NEW_LWP)\n" "\t[-p] (print benchmark summary)\n" "\t[-P] number of consecutive ports\n" "\t[-s] sleep time\n" @@ -246,7 +246,7 @@ Options::parse_args (int argc, char *argv[]) "%8d = free dynamic memory\n" "%8d = print summary only\n" "%8d = eager exit\n" - "%8d = UDP\n" + "%8d = UDP\n" "%8d = send ack\n" "%8d = THR_DETACHED\n" "%8d = THR_BOUND\n" @@ -307,8 +307,8 @@ Options::print_results (void) "%8.2f Mbit/sec\n" "%8d (voluntary context switches)\n" "%8d (involuntary context switches)\n" - "%8d (total context switches)\n" - "%8d.%d sec (wait-cpu time)\n" + "%8d (total context switches)\n" + "%8d.%d sec (wait-cpu time)\n" "%8d.%d sec (user lock wait sleep time)\n" "%8d.%d sec (all other sleep time)\n" "%8d (major page faults)\n" @@ -351,7 +351,7 @@ Options::print_results (void) "%8d = messages sent\n" "%8d = messages received\n" "%8d = signals received\n" - "%8ds, %dms = wait-cpu (latency) time\n" + "%8ds, %dms = wait-cpu (latency) time\n" "%8ds, %dms = user lock wait sleep time\n" "%8ds, %dms = all other sleep time\n" "%8d = voluntary context switches\n" @@ -394,9 +394,14 @@ Options::print_results (void) #endif /* ACE_HAS_THREADS */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) #if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0) template class ACE_Atomic_Op<ACE_Thread_Mutex, size_t>; #endif /* ACE_MT_SAFE */ -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, size_t> +#endif /* ACE_MT_SAFE */ +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Conn_Test.cpp b/tests/Conn_Test.cpp index e073aba4b57..3f5f03d8ed7 100644 --- a/tests/Conn_Test.cpp +++ b/tests/Conn_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Conn_Test.cpp // @@ -18,7 +18,7 @@ // // = AUTHOR // Doug Schmidt, Chris Cleeland -// +// // ============================================================================ #include "ace/SOCK_Connector.h" @@ -52,12 +52,12 @@ Svc_Handler::in_use (int use) int Svc_Handler::open (void *) { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) opening Svc_Handler %d with handle\n", + ACE_DEBUG ((LM_DEBUG, "(%P|%t) opening Svc_Handler %d with handle\n", this, this->peer ().get_handle ())); // Enable non-blocking I/O. if (this->peer ().enable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "enable"), -1); - + return 0; } @@ -65,9 +65,9 @@ void Svc_Handler::send_data (void) { // Send data to server. - + for (char *c = ACE_ALPHABET; *c != '\0'; c++) - if (this->peer ().send_n (c, 1) == -1) + if (this->peer ().send_n (c, 1) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "send_n")); } @@ -82,7 +82,7 @@ Svc_Handler::recv_data (void) char *t = ACE_ALPHABET; // Read data from client (terminate on error). - + for (ssize_t r_bytes; ;) { // Since we're in non-blocking mode we need to use <select> @@ -110,7 +110,7 @@ Svc_Handler::recv_data (void) if (r_bytes == 0) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) reached end of input, connection closed by client\n")); // Handshake back with client. @@ -119,14 +119,14 @@ Svc_Handler::recv_data (void) // Close endpoint handle (but don't close <this> yet since // we're going to recycle it for the next iteration). - if (new_stream.close () == -1) + if (new_stream.close () == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close")); break; } else if (r_bytes == -1) { if (errno == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) no input available, going back to reading\n")); else ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "recv_n")); @@ -167,7 +167,7 @@ ACE_Hash_Addr<ACE_INET_Addr, Svc_Handler>::hash_i (const ACE_INET_Addr &addr) co } int -ACE_Hash_Addr<ACE_INET_Addr, Svc_Handler>::compare_i (const ACE_INET_Addr &a1, +ACE_Hash_Addr<ACE_INET_Addr, Svc_Handler>::compare_i (const ACE_INET_Addr &a1, const ACE_INET_Addr &a2) const { return a1 != a2; @@ -194,7 +194,7 @@ nonblocking_connect (CONNECTOR &con, const ACE_INET_Addr &server_addr) ACE_NEW (svc_handler[1], Svc_Handler); ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting non-blocking connect\n")); - + // Perform a non-blocking connect to the server (this should connect // immediately since we're in the same address space or same host). if (con.connect (svc_handler[0], server_addr, options) == -1 @@ -211,7 +211,7 @@ nonblocking_connect (CONNECTOR &con, const ACE_INET_Addr &server_addr) // Close the connection completely. if (svc_handler[0]->close (1) == -1 - || svc_handler[1]->close (1) == -1) + || svc_handler[1]->close (1) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close")); } @@ -223,7 +223,7 @@ blocking_connect (CONNECTOR &con, const ACE_INET_Addr &server_addr) ACE_NEW (svc_handler[1], Svc_Handler); ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting blocking connect\n")); - + // Perform a blocking connect to the server. if (con.connect (svc_handler[0], server_addr) == -1 || con.connect (svc_handler[1], server_addr) == -1) @@ -239,7 +239,7 @@ blocking_connect (CONNECTOR &con, const ACE_INET_Addr &server_addr) // Close the connection completely. if (svc_handler[0]->close (1) == -1 - || svc_handler[1]->close (1) == -1) + || svc_handler[1]->close (1) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close")); } @@ -259,7 +259,7 @@ dump_map (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_Null_Mutex> &hashmap) { if (hashmap.table_[slot] == hashmap.sentinel_) continue; - + ACE_DEBUG ((LM_DEBUG, "slot %-4d: ", slot)); for (MAP_ENTRY *temp = hashmap.table_[slot]; @@ -270,8 +270,8 @@ dump_map (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_Null_Mutex> &hashmap) INT_ID& val = temp->int_id_; ACE_DEBUG ((LM_DEBUG, "(%s,%d,%sin use,0x%p), ", - key.get_host_name (), - key.get_port_number (), + key.get_host_name (), + key.get_port_number (), val->in_use() ? "" : "not ", val)); } @@ -284,7 +284,7 @@ dump_map (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_Null_Mutex> &hashmap) static void dump (STRAT_CONNECTOR &con) { - CACHED_CONNECT_STRATEGY* csp = + CACHED_CONNECT_STRATEGY* csp = (CACHED_CONNECT_STRATEGY *) con.connect_strategy_; dump_map (csp->connection_cache_); @@ -304,7 +304,7 @@ cached_connect (STRAT_CONNECTOR &con, const ACE_INET_Addr &server_addr) ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting cached blocking connect\n")); // Initiate timed, non-blocking connection with server. - + // Perform a blocking connect to the server using the Strategy // Connector with a connection caching strategy. Since we are // connecting to the same <server_addr> these calls will return the @@ -354,12 +354,12 @@ client (void *arg) { #if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) // Insert thread into thr_mgr - ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); + ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); ACE_NEW_THREAD; #endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ ACE_INET_Addr *remote_addr = (ACE_INET_Addr *) arg; - ACE_INET_Addr server_addr (remote_addr->get_port_number (), + ACE_INET_Addr server_addr (remote_addr->get_port_number (), ACE_DEFAULT_SERVER_HOST); CONNECTOR connector; @@ -368,7 +368,7 @@ client (void *arg) // connection. CACHED_CONNECT_STRATEGY caching_connect_strategy; - STRAT_CONNECTOR strat_connector (0, + STRAT_CONNECTOR strat_connector (0, &creation_strategy, &caching_connect_strategy); @@ -390,7 +390,7 @@ server (void *arg) { #if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) // Insert thread into thr_mgr - ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); + ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); ACE_NEW_THREAD; #endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ @@ -403,29 +403,29 @@ server (void *arg) ACE_NEW_RETURN (svc_handler, Svc_Handler, 0); // Create a new <Svc_Handler> to consume the data. - + int result; - while ((result = acceptor->accept (svc_handler, + while ((result = acceptor->accept (svc_handler, &cli_addr, options)) != -1) { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) client %s connected from %d\n", - cli_addr.get_host_name (), + ACE_DEBUG ((LM_DEBUG, "(%P|%t) client %s connected from %d\n", + cli_addr.get_host_name (), cli_addr.get_port_number ())); - + svc_handler->recv_data (); } if (result == -1) { if (errno == ETIMEDOUT) - ACE_ERROR ((LM_DEBUG, + ACE_ERROR ((LM_DEBUG, "(%P|%t) accept timedout, shutting down\n")); else ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "accept")); } - if (svc_handler->close () == -1) + if (svc_handler->close () == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close")); return 0; @@ -444,7 +444,7 @@ main (int, char *[]) if (acceptor.open ((const ACE_INET_Addr &) ACE_Addr::sap_any) == -1 || acceptor.acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "open")); - else + else { ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting server at port %d\n", server_addr.get_port_number ())); @@ -467,31 +467,31 @@ main (int, char *[]) /* NOTREACHED */ } #elif defined (ACE_HAS_THREADS) - if (ACE_Thread_Manager::instance ()->spawn - (ACE_THR_FUNC (server), - (void *) &acceptor, + if (ACE_Thread_Manager::instance ()->spawn + (ACE_THR_FUNC (server), + (void *) &acceptor, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); - if (ACE_Thread_Manager::instance ()->spawn - (ACE_THR_FUNC (client), - (void *) &server_addr, + if (ACE_Thread_Manager::instance ()->spawn + (ACE_THR_FUNC (client), + (void *) &server_addr, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); // Wait for the threads to exit. ACE_Thread_Manager::instance ()->wait (); #else - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "(%P|%t) only one thread may be run in a process on this platform\n%a", 1)); -#endif /* ACE_HAS_THREADS */ +#endif /* ACE_HAS_THREADS */ } ACE_END_TEST; return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Cached_Connect_Strategy<Svc_Handler, ACE_SOCK_CONNECTOR, ACE_Null_Mutex>; template class ACE_Hash_Addr<ACE_INET_Addr, Svc_Handler>; template class ACE_NOOP_Creation_Strategy<Svc_Handler>; @@ -508,4 +508,22 @@ template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Svc_Handler> *, ACE_SYN template class ACE_Strategy_Connector<Svc_Handler, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Tuple<Svc_Handler>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Cached_Connect_Strategy<Svc_Handler, ACE_SOCK_CONNECTOR, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Addr<ACE_INET_Addr, Svc_Handler> +#pragma instantiate ACE_NOOP_Creation_Strategy<Svc_Handler> +#pragma instantiate ACE_Concurrency_Strategy<Svc_Handler> +#pragma instantiate ACE_Connect_Strategy<Svc_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Connector<Svc_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Creation_Strategy<Svc_Handler> +#pragma instantiate ACE_Hash_Map_Entry<ACE_Hash_Addr<ACE_INET_Addr,Svc_Handler>, Svc_Handler *> +#pragma instantiate ACE_Hash_Map_Manager<ACE_Hash_Addr<ACE_INET_Addr,Svc_Handler>, Svc_Handler *, ACE_Null_Mutex> +#pragma instantiate ACE_Oneshot_Acceptor<Svc_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Svc_Handler> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Svc_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Svc_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Strategy_Connector<Svc_Handler, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Tuple<Svc_Handler> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Future_Test.cpp b/tests/Future_Test.cpp index 9071b6bae26..9b3d86bcc6f 100644 --- a/tests/Future_Test.cpp +++ b/tests/Future_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Future_Test.cpp // @@ -14,7 +14,7 @@ // = AUTHOR // Andres Kruse <Andres.Kruse@cern.ch>, Douglas C. Schmidt // <schmidt@cs.wustl.edu> and Per Andersson <pera@ipso.se> -// +// // ============================================================================ #include "ace/ACE.h" @@ -86,21 +86,21 @@ private: }; Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, - u_long new_param, - int new_count, + u_long new_param, + int new_count, ACE_Future<u_long> &new_result) : scheduler_ (new_Scheduler), param_ (new_param), count_ (new_count), future_result_ (new_result) -{ +{ ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work created\n")); } Method_Object_work::~Method_Object_work (void) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work will be deleted.\n")); } @@ -108,8 +108,8 @@ Method_Object_work::~Method_Object_work (void) int Method_Object_work::call (void) { - return this->future_result_.set - (this->scheduler_->work_i (this->param_, + return this->future_result_.set + (this->scheduler_->work_i (this->param_, this->count_)); } @@ -118,7 +118,7 @@ class Method_Object_name : public ACE_Method_Object // Reification of the <name> method. { public: - Method_Object_name (Scheduler *, + Method_Object_name (Scheduler *, ACE_Future<const char*> &); virtual ~Method_Object_name (void); virtual int call (void); @@ -139,7 +139,7 @@ Method_Object_name::Method_Object_name (Scheduler *new_scheduler, Method_Object_name::~Method_Object_name (void) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_name will be deleted.\n")); } @@ -157,9 +157,9 @@ public: Method_Object_end (Scheduler *new_Scheduler) : scheduler_ (new_Scheduler) {} virtual ~Method_Object_end (void) {} - virtual int call (void) { - this->scheduler_->close (); - return -1; + virtual int call (void) { + this->scheduler_->close (); + return -1; } private: @@ -167,56 +167,56 @@ private: }; // constructor -Scheduler::Scheduler (const char *newname, +Scheduler::Scheduler (const char *newname, Scheduler *new_Scheduler) { ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); ACE_OS::strcpy ((char *) this->name_, newname); this->scheduler_ = new_Scheduler; - ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s created\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s created\n", this->name_)); } // Destructor Scheduler::~Scheduler (void) { - ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s will be destroyed\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s will be destroyed\n", this->name_)); delete[] this->name_; } // open -int +int Scheduler::open (void *) { task_count++; - ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s open\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s open\n", this->name_)); // Become an Active Object. return this->activate (THR_BOUND); } // close -int +int Scheduler::close (u_long) { - ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s close\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s close\n", this->name_)); task_count--; return 0; } // service.. -int +int Scheduler::svc (void) { ACE_NEW_THREAD; - for (;;) + for (;;) { // Dequeue the next method object (we use an auto pointer in // case an exception is thrown in the <call>). @@ -233,7 +233,7 @@ Scheduler::svc (void) return 0; } -void +void Scheduler::end (void) { this->activation_queue_.enqueue (new Method_Object_end (this)); @@ -242,7 +242,7 @@ Scheduler::end (void) // Here's where the Work takes place. u_long -Scheduler::work_i (u_long param, +Scheduler::work_i (u_long param, int count) { ACE_UNUSED_ARG (count); @@ -256,25 +256,25 @@ Scheduler::name_i (void) return this->name_; } -ACE_Future<const char *> +ACE_Future<const char *> Scheduler::name (void) { - if (this->scheduler_) + if (this->scheduler_) // Delegate to the Scheduler. return this->scheduler_->name (); - else + else { ACE_Future<const char*> new_future; // @@ What happens if new fails here? - this->activation_queue_.enqueue + this->activation_queue_.enqueue (new Method_Object_name (this, new_future)); return new_future; } } -ACE_Future<u_long> +ACE_Future<u_long> Scheduler::work (u_long newparam, int newcount) { if (this->scheduler_) { @@ -284,7 +284,7 @@ Scheduler::work (u_long newparam, int newcount) ACE_Future<u_long> new_future; this->activation_queue_.enqueue - (new Method_Object_work (this, newparam, + (new Method_Object_work (this, newparam, newcount, new_future)); return new_future; } @@ -295,7 +295,7 @@ Scheduler::work (u_long newparam, int newcount) // Total number of loops. static int n_loops = 100; -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Future<const char *>; template class ACE_Future<int>; template class ACE_Future<u_long>; @@ -304,19 +304,29 @@ template class ACE_Future_Rep<int>; template class ACE_Future_Rep<u_long>; template class auto_ptr<ACE_Method_Object>; template class auto_basic_ptr<ACE_Method_Object>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Future<const char *> +#pragma instantiate ACE_Future<int> +#pragma instantiate ACE_Future<u_long> +#pragma instantiate ACE_Future_Rep<char const *> +#pragma instantiate ACE_Future_Rep<int> +#pragma instantiate ACE_Future_Rep<u_long> +#pragma instantiate auto_ptr<ACE_Method_Object> +#pragma instantiate auto_basic_ptr<ACE_Method_Object> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ int -main (int, char *[]) +main (int, char *[]) { ACE_START_TEST ("Future_Test"); #if defined (ACE_HAS_THREADS) Scheduler *andres = 0, *peter = 0, *helmut = 0, *matias = 0; - // Create active objects.. + // Create active objects.. // @@ Should "open" be subsumed within the constructor of // Scheduler()? ACE_NEW_RETURN (andres, Scheduler ("andres"), -1); @@ -330,13 +340,13 @@ main (int, char *[]) ACE_NEW_RETURN (matias, Scheduler ("matias", andres), -1); matias->open (); - for (int i = 0; i < n_loops; i++) + for (int i = 0; i < n_loops; i++) { { ACE_Future<u_long> fresulta, fresultb, fresultc, fresultd, fresulte; ACE_Future<const char*> fname; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) going to do a non-blocking call\n")); fresulta = andres->work (9013); @@ -357,7 +367,7 @@ main (int, char *[]) fresulte = fresulta; - if (i % 3 == 0) + if (i % 3 == 0) { // Every 3rd time... disconnect the futures... // but "fresulte" should still contain the result... @@ -404,7 +414,7 @@ main (int, char *[]) matias->end (); ACE_OS::sleep (2); - + ACE_DEBUG ((LM_DEBUG, "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", (int) task_count, @@ -416,10 +426,10 @@ main (int, char *[]) // Check if set then get works, older versions of ACE_Future // will lock forever (or until the timer expires), will use a small // timer value to avoid blocking the process. - + ACE_Future<int> f1; f1.set(100); - + ACE_Time_Value timeout(1); int value = 0; @@ -441,56 +451,56 @@ main (int, char *[]) ACE_Future<int> f2 (f1); // To ensure that a rep object is created } // Now it is one ACE_Future<int> referencing the rep instance - + ACE_DEBUG ((LM_DEBUG, "0.\n")); //check that self assignment works - f1 = f1; + f1 = f1; // Is there any repesentation left, and if so what is the ref // count older ACE_Future<> implementations have deleted the rep // instance at this moment - + // The stuff below might crash the process if the op= // implementation was bad int value = 0; ACE_Time_Value timeout (1); - f1.set (100); + f1.set (100); f1.get (value, &timeout); ACE_DEBUG ((LM_DEBUG, "1.\n")); - { // Might delete the same data a couple of times + { // Might delete the same data a couple of times ACE_Future<int> f2 (f1); - f1.set (100); + f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, "2.\n")); - { + { ACE_Future<int> f2 (f1); - f1.set (100); + f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, "3.\n")); - { + { ACE_Future<int> f2 (f1); - f1.set (100); + f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, "4.\n")); - { - ACE_Future<int> f2 (f1); - f1.set (100); + { + ACE_Future<int> f2 (f1); + f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, "5.\n")); - { + { ACE_Future<int> f2 (90); f2.get (value, &timeout); f1.get (value, &timeout); } } - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "No it did not crash the program.\n")); ACE_OS::sleep (5); diff --git a/tests/Handle_Set_Test.cpp b/tests/Handle_Set_Test.cpp index bb35bc1e12a..3a2df88b3fb 100644 --- a/tests/Handle_Set_Test.cpp +++ b/tests/Handle_Set_Test.cpp @@ -4,18 +4,18 @@ // // = LIBRARY // tests -// +// // = FILENAME // Handle_Set_Test.cpp // // = DESCRIPTION // This test illustrates the use of ACE_Handle_Set to maintain a // set of handles. No command line arguments are needed to run -// the test. +// the test. // // = AUTHOR // Prashant Jain -// +// // ============================================================================ #include "ace/Profile_Timer.h" @@ -61,18 +61,18 @@ test_duplicates (size_t count) } // This is the vector of handles to test. These numbers are chosen to -// test for boundaries conditions. -static ACE_HANDLE handle_vector[] = +// test for boundaries conditions. +static ACE_HANDLE handle_vector[] = { - (ACE_HANDLE) 0, - (ACE_HANDLE) 1, - (ACE_HANDLE) 32, - (ACE_HANDLE) 63, - (ACE_HANDLE) 64, - (ACE_HANDLE) 65, - (ACE_HANDLE) 127, - (ACE_HANDLE) 128, - (ACE_HANDLE) 129, + (ACE_HANDLE) 0, + (ACE_HANDLE) 1, + (ACE_HANDLE) 32, + (ACE_HANDLE) 63, + (ACE_HANDLE) 64, + (ACE_HANDLE) 65, + (ACE_HANDLE) 127, + (ACE_HANDLE) 128, + (ACE_HANDLE) 129, (ACE_HANDLE) 255, ACE_INVALID_HANDLE }; @@ -103,7 +103,7 @@ test_boundaries (void) int count = 0; - ACE_Handle_Set_Iterator i2 (handle_set); + ACE_Handle_Set_Iterator i2 (handle_set); while ((handle = i2 ()) != ACE_INVALID_HANDLE) { @@ -117,7 +117,7 @@ test_boundaries (void) } static void -test_performance (size_t max_handles, +test_performance (size_t max_handles, size_t max_iterations) { ACE_Handle_Set handle_set; @@ -177,8 +177,13 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Unbounded_Queue<ACE_HANDLE>; template class ACE_Unbounded_Queue_Iterator<ACE_HANDLE>; template class ACE_Node<ACE_HANDLE>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Unbounded_Queue<ACE_HANDLE> +#pragma instantiate ACE_Unbounded_Queue_Iterator<ACE_HANDLE> +#pragma instantiate ACE_Node<ACE_HANDLE> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Hash_Map_Manager_Test.cpp b/tests/Hash_Map_Manager_Test.cpp index 9c926c4eb11..da82fca94f6 100644 --- a/tests/Hash_Map_Manager_Test.cpp +++ b/tests/Hash_Map_Manager_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Hash_Map_Manager_Test.cpp // @@ -15,7 +15,7 @@ // // = AUTHOR // James Hu -// +// // ============================================================================ #include <iostream.h> @@ -186,7 +186,7 @@ main(void) // Scoping below so that result of destruction can be seen in the log. { HASH_STRING_MAP hash (MAX_HASH); - + hash.bind ("hello", "guten Tag"); hash.bind ("goodbye", "auf wiedersehen"); hash.bind ("funny", "lustig"); @@ -215,8 +215,13 @@ main(void) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Hash_Map_Entry<MAP_STRING, MAP_STRING>; template class ACE_Hash_Map_Manager<MAP_STRING, MAP_STRING, ACE_Null_Mutex>; template class ACE_Hash_Map_Iterator<MAP_STRING, MAP_STRING, ACE_Null_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Hash_Map_Entry<MAP_STRING, MAP_STRING> +#pragma instantiate ACE_Hash_Map_Manager<MAP_STRING, MAP_STRING, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator<MAP_STRING, MAP_STRING, ACE_Null_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/IOStream_Test.cpp b/tests/IOStream_Test.cpp index 2c57de6eec6..5cd3af5f17a 100644 --- a/tests/IOStream_Test.cpp +++ b/tests/IOStream_Test.cpp @@ -104,8 +104,8 @@ operator>> (ACE_SOCK_IOStream & stream, qchar *buf) // if we don't have a quote, append until we see space if (c != '"') - for (*buf++ = c; - (void *) stream.get(c) && !isspace(c); + for (*buf++ = c; + (void *) stream.get(c) && !isspace(c); *buf++ = c) continue; else @@ -118,7 +118,7 @@ operator>> (ACE_SOCK_IOStream & stream, qchar *buf) } *buf = '\0'; - + return stream; } @@ -168,13 +168,13 @@ client (void *arg = 0) ACE_SOCK_IOStream &server = *server_p; ACE_INET_Addr *remote_addr = (ACE_INET_Addr *) arg; - ACE_INET_Addr addr (remote_addr->get_port_number (), + ACE_INET_Addr addr (remote_addr->get_port_number (), ACE_DEFAULT_SERVER_HOST); ACE_SOCK_Connector connector; if (connector.connect (server, addr) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%t) %p\n", "Failed to connect to server thread"), + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) %p\n", "Failed to connect to server thread"), 0); // Send a string to the server which it can interpret as a qchar[] @@ -203,7 +203,7 @@ client (void *arg = 0) // the server. ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client Receiving\n")); - + int i; float f1, f2; long l; @@ -214,13 +214,13 @@ client (void *arg = 0) server >> f2; server >> d; - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Client Received: int %d float %f long %d float %f double %f\n", + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Client Received: int %d float %f long %d float %f double %f\n", i, f1, (int) l, f2, d)); // Check for proper received values. - ACE_ASSERT (i == 1 && (f1 >= 0.123420 && f1 <= 0.123422) - && l == 666555444 && (f2 >= 23.44 && f2 <= 23.46) + ACE_ASSERT (i == 1 && (f1 >= 0.123420 && f1 <= 0.123422) + && l == 666555444 && (f2 >= 23.44 && f2 <= 23.46) && (d >= -47.1e+9 && d <= -45.9e+9)); // Reset the precision to limit ourselves to two significant digits. server.precision (2); @@ -267,16 +267,16 @@ server (void *arg = 0) #if defined (ACE_HAS_THREADS) ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); - if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (client), + if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (client), (void *) &server_addr, THR_NEW_LWP | THR_DETACHED) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%t) %p\n", "spawing client thread"), + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) %p\n", "spawing client thread"), 0); #endif /* ACE_HAS_THREADS */ if (acceptor->accept (client_handler) == -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Failed to accept new client_handler"), 0); @@ -285,8 +285,8 @@ server (void *arg = 0) qchar qbuf[BUFSIZ]; ACE_OS::memset (qbuf, 0, sizeof qbuf); client_handler >> qbuf; - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Server Received: (\"%s\")\n", + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Server Received: (\"%s\")\n", qbuf)); // Give the client time to announce the next test to the user. @@ -300,7 +300,7 @@ server (void *arg = 0) ACE_OS::memset (buf, 0, sizeof buf); ACE_DEBUG ((LM_DEBUG, "(%P|%t) Server Received: (")); - while (ACE_OS::strlen (buf) == 0 + while (ACE_OS::strlen (buf) == 0 || buf[ACE_OS::strlen (buf) - 1] != '"') { client_handler >> buf; @@ -333,13 +333,13 @@ server (void *arg = 0) double d; client_handler >> i >> f1 >> l >> f2 >> d; - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Server Received: int %d float %g long %d float %g double %g\n", + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Server Received: int %d float %g long %d float %g double %g\n", i, f1, (int) l, f2, d)); // check for proper received values ACE_ASSERT (i == -1 && (f1 >= -0.13 && f1 <= -0.11) - && l == -666555444 && (f2 >= -24.0 && f2 <= -22.0) + && l == -666555444 && (f2 >= -24.0 && f2 <= -22.0) && (d >= -45e+9 && d <= 47e+9)); delete client_handler_p; @@ -359,8 +359,8 @@ spawn (void) else if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (server), &acceptor, THR_NEW_LWP | THR_DETACHED) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", "spawning server thread"), + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", "spawning server thread"), -1); // Wait for the client and server thread to exit. @@ -391,10 +391,10 @@ spawn (void) break; } #else - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "threads *and* processes not supported on this platform\n%"), -1); -#endif /* ACE_HAS_THREADS */ +#endif /* ACE_HAS_THREADS */ return 0; } #endif /* !ACE_LACKS_ACE_IOSTREAM */ @@ -415,8 +415,12 @@ main (int, char *[]) #if !defined (ACE_LACKS_ACE_IOSTREAM) -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_IOStream_T<ACE_SOCK_Stream>; template class ACE_Streambuf_T<ACE_SOCK_Stream>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_IOStream_T<ACE_SOCK_Stream> +#pragma instantiate ACE_Streambuf_T<ACE_SOCK_Stream> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* !ACE_LACKS_ACE_IOSTREAM */ diff --git a/tests/Map_Manager_Test.cpp b/tests/Map_Manager_Test.cpp index 913ed65c24b..12707e1d6d5 100644 --- a/tests/Map_Manager_Test.cpp +++ b/tests/Map_Manager_Test.cpp @@ -4,18 +4,18 @@ // // = LIBRARY // tests -// +// // = FILENAME // Map_Manager_Test.cpp // // = DESCRIPTION // This is a simple test of the ACE_Map_Manager and // ACE_Hash_Map_Manager that illustrates how to use the forward -// and reverse iterators. +// and reverse iterators. // // = AUTHOR // Irfan Pyarali and Douglas C. Schmidt -// +// // ============================================================================ #include "ace/Map_Manager.h" @@ -46,7 +46,7 @@ typedef ACE_Hash_Map_Manager <KEY, VALUE, MUTEX> HASH_MAP_MANAGER; typedef ACE_Hash_Map_Iterator <KEY, VALUE, MUTEX> HASH_ITERATOR; typedef ACE_Hash_Map_Entry <KEY, VALUE> HASH_ENTRY; -static void +static void test_hash_map_manager (size_t table_size, size_t iterations) { HASH_MAP_MANAGER map (table_size); @@ -57,7 +57,7 @@ test_hash_map_manager (size_t table_size, size_t iterations) ACE_ASSERT (map.bind (KEY (i), i) != -1); { - HASH_ITERATOR iterator (map); + HASH_ITERATOR iterator (map); for (HASH_ENTRY *entry = 0; iterator.next (entry) != 0; @@ -97,7 +97,7 @@ test_map_manager (size_t table_size, size_t iterations) ACE_ASSERT (map.bind (KEY (i), i) != -1); { - ITERATOR iterator (map); + ITERATOR iterator (map); for (ENTRY *entry = 0; iterator.next (entry) != 0; @@ -144,7 +144,7 @@ test_map_manager (size_t table_size, size_t iterations) ACE_ASSERT (map.current_size () == 0); } -static void +static void run_test (void (*ptf) (size_t, size_t), size_t table_size, size_t iterations, @@ -161,16 +161,16 @@ run_test (void (*ptf) (size_t, size_t), timer.elapsed_time (et); - ACE_DEBUG ((LM_DEBUG, "time to test a %d item map for %d iterations using %s\n", + ACE_DEBUG ((LM_DEBUG, "time to test a %d item map for %d iterations using %s\n", table_size, iterations, test_name)); ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); - ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); } -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { ACE_START_TEST ("Map_Manager_Test"); @@ -189,7 +189,7 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Hash_Map_Manager<KEY, VALUE, MUTEX>; template class ACE_Hash_Map_Iterator<KEY, VALUE, MUTEX>; template class ACE_Hash_Map_Entry<KEY, VALUE>; @@ -197,4 +197,13 @@ template class ACE_Map_Manager<KEY, VALUE, MUTEX>; template class ACE_Map_Iterator<KEY, VALUE, MUTEX>; template class ACE_Map_Reverse_Iterator<KEY, VALUE, MUTEX>; template class ACE_Map_Entry<KEY, VALUE>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Hash_Map_Manager<KEY, VALUE, MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator<KEY, VALUE, MUTEX> +#pragma instantiate ACE_Hash_Map_Entry<KEY, VALUE> +#pragma instantiate ACE_Map_Manager<KEY, VALUE, MUTEX> +#pragma instantiate ACE_Map_Iterator<KEY, VALUE, MUTEX> +#pragma instantiate ACE_Map_Reverse_Iterator<KEY, VALUE, MUTEX> +#pragma instantiate ACE_Map_Entry<KEY, VALUE> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Message_Block_Test.cpp b/tests/Message_Block_Test.cpp index aaa4830cad8..eb6e027b84a 100644 --- a/tests/Message_Block_Test.cpp +++ b/tests/Message_Block_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Message_Block_Test.cpp // @@ -15,7 +15,7 @@ // // = AUTHOR // Doug Schmidt and Nanbor Wang -// +// // ============================================================================ #include "ace/Task.h" @@ -61,9 +61,9 @@ private: // Close hook. }; -int -Worker_Task::close (u_long) -{ +int +Worker_Task::close (u_long) +{ ACE_DEBUG ((LM_DEBUG, "(%t) close of worker\n")); return 0; } @@ -72,15 +72,15 @@ Worker_Task::close (u_long) int Worker_Task::put (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - return this->msg_queue ()->enqueue_prio (mb, tv); +{ + return this->msg_queue ()->enqueue_prio (mb, tv); } // Iterate <n_iterations> printing off a message and "waiting" for all // other threads to complete this iteration. -int -Worker_Task::svc (void) +int +Worker_Task::svc (void) { ACE_NEW_THREAD; // The <ACE_Task::svc_run()> method automatically adds us to the @@ -88,12 +88,12 @@ Worker_Task::svc (void) // begins. ACE_DEBUG ((LM_DEBUG, "(%t) starting svc() method\n")); - + // Keep looping, reading a message out of the queue, until we get a // message with a length == 0, which signals us to quit. for (int count = 0; ; count++) - { + { ACE_Message_Block *mb; ACE_ASSERT (this->msg_queue ()->dequeue_head (mb) != -1); @@ -117,7 +117,7 @@ Worker_Task::svc (void) ACE_ASSERT (count == current_count); - ACE_DEBUG ((LM_DEBUG, "(%t) enqueueing %d duplicates\n", + ACE_DEBUG ((LM_DEBUG, "(%t) enqueueing %d duplicates\n", current_count)); ACE_Message_Block *dup; @@ -133,8 +133,8 @@ Worker_Task::svc (void) // threads. dup->msg_priority (1); - ACE_ASSERT (this->msg_queue ()->enqueue_prio - (dup, + ACE_ASSERT (this->msg_queue ()->enqueue_prio + (dup, // Don't block indefinitely if we flow control... (ACE_Time_Value *) &ACE_Time_Value::zero) != -1); } @@ -152,11 +152,11 @@ Worker_Task::svc (void) dup->release (); } - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d, length = %d, prio = %d, text = \"%*s\"\n", - count, - length, - mb->msg_priority (), + count, + length, + mb->msg_priority (), length - 2, // remove the trailing "\n\0" mb->rd_ptr ())); } @@ -166,7 +166,7 @@ Worker_Task::svc (void) if (length == 0) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d, queue len = %d, got NULL message, exiting\n", count, this->msg_queue ()->message_count ())); break; @@ -183,7 +183,7 @@ Worker_Task::Worker_Task (void) // Make us an Active Object. if (this->activate (THR_NEW_LWP) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); -} +} static int produce (Worker_Task &worker_task, @@ -200,7 +200,7 @@ produce (Worker_Task &worker_task, int n = ACE_OS::strlen (buf) + 1; // Allocate a new message. - ACE_NEW_RETURN (mb, + ACE_NEW_RETURN (mb, ACE_Message_Block (n, // size ACE_Message_Block::MB_DATA, // type 0, // cont @@ -214,18 +214,18 @@ produce (Worker_Task &worker_task, mb->copy (buf, n); // Pass the message to the Worker_Task. - if (worker_task.put (mb, + if (worker_task.put (mb, // Don't block indefinitely if we flow control... (ACE_Time_Value *) &ACE_Time_Value::zero) == -1) ACE_ERROR ((LM_ERROR, " (%t) %p\n", "put")); } // Send a shutdown message to the waiting threads and exit. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "\n(%t) sending shutdown message\n")); - ACE_NEW_RETURN (mb, - ACE_Message_Block (0, ACE_Message_Block::MB_DATA, + ACE_NEW_RETURN (mb, + ACE_Message_Block (0, ACE_Message_Block::MB_DATA, 0, 0, alloc_strategy, &lock_adapter_), -1); @@ -240,7 +240,7 @@ produce (Worker_Task &worker_task, typedef char MEMORY_CHUNK[ACE_MALLOC_ALIGN * ACE_ALLOC_SIZE]; ACE_Cached_Allocator<MEMORY_CHUNK, - ACE_SYNCH_MUTEX> + ACE_SYNCH_MUTEX> mem_allocator (ACE_ALLOC_AMOUNT); struct @@ -254,7 +254,7 @@ struct { &mem_allocator, "Cached Memory" } }; -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Cached_Allocator<MEMORY_CHUNK, ACE_SYNCH_MUTEX>; template class ACE_Cached_Mem_Pool_Node<MEMORY_CHUNK>; template class ACE_Locked_Free_List<ACE_Cached_Mem_Pool_Node<MEMORY_CHUNK>, ACE_SYNCH_MUTEX>; @@ -262,17 +262,26 @@ template class ACE_Free_List<ACE_Cached_Mem_Pool_Node<MEMORY_CHUNK> >; template class ACE_Lock_Adapter<ACE_SYNCH_MUTEX>; template class ACE_Message_Queue_Iterator<ACE_NULL_SYNCH>; template class ACE_Message_Queue_Reverse_Iterator<ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Cached_Allocator<MEMORY_CHUNK, ACE_SYNCH_MUTEX> +#pragma instantiate ACE_Cached_Mem_Pool_Node<MEMORY_CHUNK> +#pragma instantiate ACE_Locked_Free_List<ACE_Cached_Mem_Pool_Node<MEMORY_CHUNK>, ACE_SYNCH_MUTEX> +#pragma instantiate ACE_Free_List<ACE_Cached_Mem_Pool_Node<MEMORY_CHUNK> > +#pragma instantiate ACE_Lock_Adapter<ACE_SYNCH_MUTEX> +#pragma instantiate ACE_Message_Queue_Iterator<ACE_NULL_SYNCH> +#pragma instantiate ACE_Message_Queue_Reverse_Iterator<ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ -int +int main (int, char *[]) { ACE_START_TEST ("Message_Block_Test"); #if defined (ACE_HAS_THREADS) int n_threads = ACE_MAX_THREADS; - + ACE_DEBUG ((LM_DEBUG, "(%t) threads = %d\n", n_threads)); ACE_Profile_Timer ptime; @@ -287,7 +296,7 @@ main (int, char *[]) // Create the worker tasks. Worker_Task worker_task[ACE_MAX_THREADS] ; - + // Link all the tasks together into a simple pipeline. for (int j = 1; j < ACE_MAX_THREADS; j++) worker_task[j - 1].next (&worker_task[j]); @@ -297,10 +306,10 @@ main (int, char *[]) produce (worker_task[0], alloc_struct[i].strategy_); // Wait for all the threads to reach their exit point. - + ACE_DEBUG ((LM_DEBUG, "(%t) waiting for worker tasks to finish...\n")); - + ACE_Thread_Manager::instance ()->wait (); ptime.stop (); ptime.elapsed_time (alloc_struct[i].et_); diff --git a/tests/Message_Queue_Test.cpp b/tests/Message_Queue_Test.cpp index d79b9c5af0b..20250e82612 100644 --- a/tests/Message_Queue_Test.cpp +++ b/tests/Message_Queue_Test.cpp @@ -4,17 +4,17 @@ // // = LIBRARY // tests -// +// // = FILENAME // Message_Queue_Test.cpp // // = DESCRIPTION // This is a simple test of the ACE_Message_Queue that -// illustrates how to use the forward and reverse iterators. +// illustrates how to use the forward and reverse iterators. // // = AUTHOR // Irfan Pyarali -// +// // ============================================================================ #include "ace/Message_Queue.h" @@ -25,7 +25,7 @@ typedef ACE_Message_Queue <ACE_NULL_SYNCH> QUEUE; typedef ACE_Message_Queue_Iterator <ACE_NULL_SYNCH> ITERATOR; typedef ACE_Message_Queue_Reverse_Iterator <ACE_NULL_SYNCH> REVERSE_ITERATOR; -int +int main (int, char *[]) { ACE_START_TEST ("Message_Queue_Test"); @@ -45,10 +45,10 @@ main (int, char *[]) if (queue.enqueue (entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, "QUEUE::enqueue\n"), -1); } - + ACE_DEBUG ((LM_DEBUG, "\nForward Iterations\n")); { - ITERATOR iterator (queue); + ITERATOR iterator (queue); for (ACE_Message_Block *entry = 0; iterator.next (entry) != 0; @@ -75,7 +75,7 @@ main (int, char *[]) iterator.advance ()) ACE_DEBUG ((LM_DEBUG, "%s\n", entry->base ())); } - + ACE_DEBUG ((LM_DEBUG, "\nReverse Iterations\n")); { QUEUE::REVERSE_ITERATOR iterator (queue); @@ -90,7 +90,11 @@ main (int, char *[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Message_Queue_Iterator<ACE_NULL_SYNCH>; template class ACE_Message_Queue_Reverse_Iterator<ACE_NULL_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Message_Queue_Iterator<ACE_NULL_SYNCH> +#pragma instantiate ACE_Message_Queue_Reverse_Iterator<ACE_NULL_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Process_Strategy_Test.cpp b/tests/Process_Strategy_Test.cpp index b1719ddbcbd..4a7e698e6c6 100644 --- a/tests/Process_Strategy_Test.cpp +++ b/tests/Process_Strategy_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Process_Strategy_Test.cpp // @@ -33,7 +33,7 @@ // // = AUTHOR // Doug Schmidt and Kevin Boyle <kboyle@sanwafp.com> -// +// // ============================================================================ #include "ace/Acceptor.h" @@ -66,7 +66,7 @@ public: protected: // = Methods invoked via "pointer to method" table entry. - + virtual int svc (void); // Handle the THREAD case. @@ -86,7 +86,7 @@ protected: // Define a <Strategy_Acceptor> that's parameterized by the // <Counting_Service>. -typedef ACE_Strategy_Acceptor <Counting_Service, ACE_SOCK_ACCEPTOR> +typedef ACE_Strategy_Acceptor <Counting_Service, ACE_SOCK_ACCEPTOR> ACCEPTOR; class Options : public ACE_Event_Handler @@ -159,7 +159,7 @@ Options::filename (void) } Options::Options (void) - : + : #if !defined (ACE_LACKS_EXEC) concurrency_type_ (PROCESS) #elif defined (ACE_HAS_THREADS) @@ -196,20 +196,20 @@ Options::parse_args (int argc, char *argv[]) this->filename_ = get_opt.optarg; break; default: - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "usage: %n [-f (filename)] [-c (concurrency strategy)]\n%a", 1)); /* NOTREACHED */ } // Initialize the file lock. - if (this->file_lock_.open (ACE_WIDE_STRING (this->filename_), - O_RDWR | O_CREAT, + if (this->file_lock_.open (ACE_WIDE_STRING (this->filename_), + O_RDWR | O_CREAT, ACE_DEFAULT_FILE_PERMS) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); // Note that this object lives beyond the lifetime of the Acceptor. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) opening %s on handle %d.\n", this->filename_, this->file_lock_.get_handle ())); @@ -226,8 +226,8 @@ Options::parse_args (int argc, char *argv[]) { case Options::PROCESS: #if !defined (ACE_LACKS_EXEC) - ACE_NEW_RETURN (this->concurrency_strategy_, - ACE_Process_Strategy<Counting_Service> + ACE_NEW_RETURN (this->concurrency_strategy_, + ACE_Process_Strategy<Counting_Service> (1, this, ACE_Reactor::instance()), -1); break; @@ -236,8 +236,8 @@ Options::parse_args (int argc, char *argv[]) #endif /* !defined (ACE_LACKS_EXEC) */ case Options::THREAD: #if defined (ACE_HAS_THREADS) - ACE_NEW_RETURN (this->concurrency_strategy_, - ACE_Thread_Strategy<Counting_Service> + ACE_NEW_RETURN (this->concurrency_strategy_, + ACE_Thread_Strategy<Counting_Service> (ACE_Thread_Manager::instance (), THR_NEW_LWP, 1), -1); @@ -247,8 +247,8 @@ Options::parse_args (int argc, char *argv[]) #endif /* !ACE_HAS_THREADS */ case Options::REACTIVE: // Settle for the purely Reactive strategy. - ACE_NEW_RETURN (this->concurrency_strategy_, - ACE_Reactive_Strategy<Counting_Service> + ACE_NEW_RETURN (this->concurrency_strategy_, + ACE_Reactive_Strategy<Counting_Service> (ACE_Reactor::instance()), -1); break; @@ -264,13 +264,13 @@ Options::parse_args (int argc, char *argv[]) return 0; } -Options::Concurrency_Type +Options::Concurrency_Type Options::concurrency_type (void) { return this->concurrency_type_; } -void +void Options::concurrency_type (Options::Concurrency_Type cs) { this->concurrency_type_ = cs; @@ -317,7 +317,7 @@ Counting_Service::read (void) OPTIONS::instance ()->file_lock ().get_handle ())); int count; - if (ACE_OS::pread (OPTIONS::instance ()->file_lock ().get_handle (), + if (ACE_OS::pread (OPTIONS::instance ()->file_lock ().get_handle (), (void *) &count, sizeof count, 0) != sizeof count) @@ -343,7 +343,7 @@ Counting_Service::inc (void) { ACE_WRITE_GUARD_RETURN (ACE_File_Lock, ace_mon, OPTIONS::instance ()->file_lock (), -1); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) incrementing on handle %d.\n", OPTIONS::instance ()->file_lock ().get_handle ())); @@ -359,7 +359,7 @@ Counting_Service::inc (void) count, count + 1)); count++; - if (ACE_OS::pwrite (OPTIONS::instance ()->file_lock ().get_handle (), + if (ACE_OS::pwrite (OPTIONS::instance ()->file_lock ().get_handle (), (const void *) &count, sizeof count, 0) != sizeof count) @@ -370,12 +370,12 @@ Counting_Service::inc (void) // Receive the request from the client and call the appropriate // operation. -int +int Counting_Service::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) reading from peer on %d\n", this->peer ().get_handle ())); @@ -392,7 +392,7 @@ Counting_Service::handle_input (ACE_HANDLE) return -1; else { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) %d bytes of input on %d is %*s\n", len, this->peer ().get_handle (), bytes, buf)); @@ -423,10 +423,10 @@ Counting_Service::svc (void) // This method is called back by the <Acceptor> once the client has // connected and the process is forked or spawned. -int +int Counting_Service::open (void *) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) opening service\n")); if (OPTIONS::instance ()->concurrency_type () == Options::PROCESS) @@ -437,7 +437,7 @@ Counting_Service::open (void *) while (this->handle_input () >= 0) continue; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%P|%t) About to exit from the child\n")); // Exit the child. @@ -453,7 +453,7 @@ client (void *arg) { #if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) // Insert thread into thr_mgr - ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); + ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); ACE_NEW_THREAD; #endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ @@ -493,8 +493,8 @@ client (void *arg) else if (stream.recv (buf, sizeof buf) <= 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), 0); - // ACE_DEBUG ((LM_DEBUG, - // "(%P|%t) client iteration %d, buf = %s\n", + // ACE_DEBUG ((LM_DEBUG, + // "(%P|%t) client iteration %d, buf = %s\n", // i, buf)); if (stream.close () == -1) @@ -540,7 +540,7 @@ server (void *) { #if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) // Insert thread into thr_mgr - ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); + ACE_Thread_Control thread_control (ACE_Thread_Manager::instance ()); ACE_NEW_THREAD; #endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ @@ -606,31 +606,31 @@ main (int argc, char *argv[]) /* NOTREACHED */ } #elif defined (ACE_HAS_THREADS) - if (ACE_Thread_Manager::instance ()->spawn - (ACE_THR_FUNC (server), + if (ACE_Thread_Manager::instance ()->spawn + (ACE_THR_FUNC (server), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); - if (ACE_Thread_Manager::instance ()->spawn - (ACE_THR_FUNC (client), - (void *) &server_addr, + if (ACE_Thread_Manager::instance ()->spawn + (ACE_THR_FUNC (client), + (void *) &server_addr, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); // Wait for the threads to exit. ACE_Thread_Manager::instance ()->wait (); #else - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "(%P|%t) only one thread may be run in a process on this platform\n%a", 1)); -#endif /* ACE_HAS_THREADS */ +#endif /* ACE_HAS_THREADS */ } ACE_END_TEST; return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Accept_Strategy<Counting_Service, ACE_SOCK_ACCEPTOR>; template class ACE_Acceptor<Counting_Service, ACE_SOCK_ACCEPTOR>; template class ACE_Creation_Strategy<Counting_Service>; @@ -645,4 +645,20 @@ template class ACE_Scheduling_Strategy<Counting_Service>; template class ACE_Strategy_Acceptor<Counting_Service, ACE_SOCK_ACCEPTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class ACE_Write_Guard<ACE_File_Lock>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Accept_Strategy<Counting_Service, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Acceptor<Counting_Service, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Creation_Strategy<Counting_Service> +#pragma instantiate ACE_Concurrency_Strategy<Counting_Service> +#pragma instantiate ACE_Guard<ACE_File_Lock> +#pragma instantiate ACE_Singleton<Options, ACE_Null_Mutex> +#pragma instantiate ACE_Process_Strategy<Counting_Service> +#pragma instantiate ACE_Thread_Strategy<Counting_Service> +#pragma instantiate ACE_Reactive_Strategy<Counting_Service> +#pragma instantiate ACE_Read_Guard<ACE_File_Lock> +#pragma instantiate ACE_Scheduling_Strategy<Counting_Service> +#pragma instantiate ACE_Strategy_Acceptor<Counting_Service, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Write_Guard<ACE_File_Lock> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Reader_Writer_Test.cpp b/tests/Reader_Writer_Test.cpp index dab76084aad..3426a26f371 100644 --- a/tests/Reader_Writer_Test.cpp +++ b/tests/Reader_Writer_Test.cpp @@ -4,18 +4,18 @@ // // = LIBRARY // tests -// +// // = FILENAME // Reader_Writer_Test.cpp // // = DESCRIPTION // This test program verifies the functionality of the ACE_OS // implementation of readers/writer locks on Win32 and Posix -// pthreads. +// pthreads. // // = AUTHOR // Prashant Jain and Doug C. Schmidt -// +// // ============================================================================ #include "ace/Synch.h" @@ -39,20 +39,20 @@ static size_t n_readers = 6; static size_t n_writers = 4; // Thread id of last writer. -static ACE_thread_t shared_data; +static ACE_thread_t shared_data; // Lock for shared_data. -static ACE_RW_Mutex rw_mutex; +static ACE_RW_Mutex rw_mutex; // Count of the number of readers and writers. static ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers; static ACE_Atomic_Op<ACE_Thread_Mutex, int> current_writers; // Explain usage and exit. -static void +static void print_usage_and_die (void) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "usage: %n [-r n_readers] [-w n_writers] [-n iteration_count]\n")); ACE_OS::exit (1); } @@ -62,7 +62,7 @@ parse_args (int argc, char *argv[]) { ACE_Get_Opt get_opt (argc, argv, "r:w:n:"); - int c; + int c; while ((c = get_opt ()) != -1) switch (c) @@ -81,7 +81,7 @@ parse_args (int argc, char *argv[]) break; } } - + // Iterate <n_iterations> each time checking that nobody modifies the data // while we have a read lock. @@ -92,7 +92,7 @@ reader (void *) ACE_NEW_THREAD; ACE_DEBUG ((LM_DEBUG, " (%t) reader starting\n")); - + for (size_t iterations = 1; iterations <= n_iterations; iterations++) { ACE_Read_Guard<ACE_RW_Mutex> g (rw_mutex); @@ -101,7 +101,7 @@ reader (void *) if (current_writers > 0) ACE_DEBUG ((LM_DEBUG, " (%t) writers found!!!\n")); - + ACE_thread_t data = shared_data; for (size_t loop = 1; loop <= n_loops; loop++) @@ -109,8 +109,8 @@ reader (void *) ACE_Thread::yield (); if (!ACE_OS::thr_equal (shared_data, data)) - ACE_DEBUG ((LM_DEBUG, - " (%t) somebody changed %d to %d\n", + ACE_DEBUG ((LM_DEBUG, + " (%t) somebody changed %d to %d\n", data, shared_data)); } @@ -132,7 +132,7 @@ writer (void *) ACE_NEW_THREAD; ACE_DEBUG ((LM_DEBUG, " (%t) writer starting\n")); - + for (size_t iterations = 1; iterations <= n_iterations; iterations++) { ACE_Write_Guard<ACE_RW_Mutex> g (rw_mutex); @@ -145,7 +145,7 @@ writer (void *) if (current_readers > 0) ACE_DEBUG ((LM_DEBUG, " (%t) readers found!!!\n")); - + ACE_thread_t self = ACE_Thread::self (); shared_data = self; @@ -155,8 +155,8 @@ writer (void *) ACE_Thread::yield (); if (!ACE_OS::thr_equal (shared_data, self)) - ACE_DEBUG ((LM_DEBUG, - " (%t) somebody wrote on my data %d\n", + ACE_DEBUG ((LM_DEBUG, + " (%t) somebody wrote on my data %d\n", shared_data)); } @@ -184,14 +184,14 @@ int main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, " (%t) main thread starting\n")); - if (ACE_Thread_Manager::instance ()->spawn_n (n_readers, - ACE_THR_FUNC (reader), - 0, + if (ACE_Thread_Manager::instance ()->spawn_n (n_readers, + ACE_THR_FUNC (reader), + 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); - else if (ACE_Thread_Manager::instance ()->spawn_n (n_writers, - ACE_THR_FUNC (writer), - 0, + else if (ACE_Thread_Manager::instance ()->spawn_n (n_writers, + ACE_THR_FUNC (writer), + 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); @@ -207,8 +207,13 @@ int main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Read_Guard<ACE_RW_Mutex>; template class ACE_Write_Guard<ACE_RW_Mutex>; template class ACE_Guard<ACE_RW_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Read_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Guard<ACE_RW_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp index 18a95c95ff8..f8df6c99335 100644 --- a/tests/SV_Shared_Memory_Test.cpp +++ b/tests/SV_Shared_Memory_Test.cpp @@ -4,17 +4,17 @@ // // = LIBRARY // tests -// +// // = FILENAME // SV_Shared_Memory_Test.cpp // // = DESCRIPTION // This is a simple test of ACE_SV_Shared_Memory and ACE_Malloc -// using the ACE_Shared_Memory_Pool. +// using the ACE_Shared_Memory_Pool. // // = AUTHOR // Prashant Jain and Doug Schmidt -// +// // ============================================================================ #include "ace/Malloc.h" @@ -87,12 +87,18 @@ child (char *shm) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple>; template class ACE_Guard<ACE_SV_Semaphore_Simple>; template class ACE_Write_Guard<ACE_SV_Semaphore_Simple>; template class ACE_Read_Guard<ACE_SV_Semaphore_Simple>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Guard<ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Write_Guard<ACE_SV_Semaphore_Simple> +#pragma instantiate ACE_Read_Guard<ACE_SV_Semaphore_Simple> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_SYSV_IPC */ @@ -118,7 +124,7 @@ main (int, char *[]) break; } #else - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "SYSV IPC is not supported on this platform\n")); #endif /* ACE_HAS_SYSV_IPC */ ACE_END_TEST; diff --git a/tests/Service_Config_Test.cpp b/tests/Service_Config_Test.cpp index 79699e77a3b..04019f529b6 100644 --- a/tests/Service_Config_Test.cpp +++ b/tests/Service_Config_Test.cpp @@ -92,8 +92,13 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class mySingleton<1>; template class mySingleton<2>; template class mySingleton<3>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate mySingleton<1> +#pragma instantiate mySingleton<2> +#pragma instantiate mySingleton<3> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/Simple_Message_Block_Test.cpp b/tests/Simple_Message_Block_Test.cpp index 378af323a28..4f2b79accd2 100644 --- a/tests/Simple_Message_Block_Test.cpp +++ b/tests/Simple_Message_Block_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Simple_Message_Block_Test.cpp // @@ -17,18 +17,18 @@ // // = AUTHOR // Irfan Pyarali (irfan@cs.wustl.edu) -// +// // ============================================================================ #include "ace/Message_Block.h" #include "ace/Synch.h" #include "test_config.h" -int +int main (void) { ACE_START_TEST ("Simple_Message_Block_Test"); - + { // Checks normal stack deletes. ACE_Message_Block mb; @@ -46,7 +46,7 @@ main (void) // Checks continuation of message blocks on the stack. ACE_Message_Block mb1 (1024); ACE_Message_Block mb2 (1024); - + mb1.cont (&mb2); } @@ -54,7 +54,7 @@ main (void) // Checks continuation of message blocks on the heap. ACE_Message_Block *mb1; ACE_Message_Block *mb2; - + ACE_NEW_RETURN (mb1, ACE_Message_Block (1024), -1); ACE_NEW_RETURN (mb2, ACE_Message_Block (1024), -1); @@ -66,7 +66,7 @@ main (void) { ACE_Lock_Adapter <ACE_SYNCH_MUTEX> mutex; ACE_Lock *lock = &mutex; - + { // Checks normal stack deletes. ACE_Message_Block mb; @@ -85,7 +85,7 @@ main (void) // Checks continuation of message blocks on the stack with one // lock strategy. ACE_Message_Block mb1 (1024); - ACE_Message_Block mb2 (1024); + ACE_Message_Block mb2 (1024); mb1.locking_strategy (lock); @@ -97,7 +97,7 @@ main (void) // lock strategy. ACE_Message_Block *mb1; ACE_Message_Block *mb2; - + ACE_NEW_RETURN (mb1, ACE_Message_Block (1024), -1); ACE_NEW_RETURN (mb2, ACE_Message_Block (1024), -1); @@ -111,7 +111,7 @@ main (void) // Checks continuation of message blocks on the stack with two // lock strategy. ACE_Message_Block mb1 (1024); - ACE_Message_Block mb2 (1024); + ACE_Message_Block mb2 (1024); mb1.locking_strategy (lock); mb2.locking_strategy (lock); @@ -124,7 +124,7 @@ main (void) // lock strategy ACE_Message_Block *mb1; ACE_Message_Block *mb2; - + ACE_NEW_RETURN (mb1, ACE_Message_Block (1024), -1); ACE_NEW_RETURN (mb2, ACE_Message_Block (1024), -1); @@ -159,7 +159,7 @@ main (void) ACE_Message_Block *mb1; ACE_Message_Block *mb2; - + ACE_NEW_RETURN (mb1, ACE_Message_Block (1024), -1); ACE_NEW_RETURN (mb2, ACE_Message_Block (1024), -1); @@ -172,8 +172,11 @@ main (void) ACE_END_TEST; return 0; -} +} -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Lock_Adapter<ACE_SYNCH_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Lock_Adapter<ACE_SYNCH_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/tests/TSS_Test.cpp b/tests/TSS_Test.cpp index 8e540ee58ee..9fd64e866ae 100644 --- a/tests/TSS_Test.cpp +++ b/tests/TSS_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // TSS_Test.cpp // @@ -13,11 +13,11 @@ // wrapper transparently ensures that the objects of this class // will be placed in thread-specific storage. All calls on // ACE_TSS::operator->() are delegated to the appropriate method -// in the Errno class. +// in the Errno class. // // = AUTHOR // Prashant Jain and Doug Schmidt -// +// // ============================================================================ #include "ace/Service_Config.h" @@ -25,7 +25,7 @@ #include "TSS_Test_Errno.h" #include "test_config.h" -#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_THREADS) static const int ITERATIONS = 100; @@ -48,7 +48,7 @@ static ACE_Null_Mutex cout_lock; typedef ACE_Guard<ACE_Null_Mutex> GUARD; #endif /* ACE_HAS_THREADS */ -extern "C" void +extern "C" void cleanup (void *ptr) { ACE_DEBUG ((LM_DEBUG, "(%t) in cleanup, ptr = %x\n", ptr)); @@ -146,24 +146,27 @@ worker (void *c) return 0; } -extern "C" void +extern "C" void handler (int signum) { ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); ACE_Thread_Manager::instance ()->exit (0); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_TSS<Errno>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_TSS<Errno> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ -int +int main (int, char *[]) { ACE_START_TEST ("TSS_Test"); - + #if defined (ACE_HAS_THREADS) ACE_Thread_Control tc (ACE_Thread_Manager::instance ()); @@ -171,15 +174,15 @@ main (int, char *[]) ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); ACE_UNUSED_ARG (sa); - if (ACE_Thread_Manager::instance ()->spawn_n (ACE_MAX_THREADS, - ACE_THR_FUNC (&worker), + if (ACE_Thread_Manager::instance ()->spawn_n (ACE_MAX_THREADS, + ACE_THR_FUNC (&worker), (void *) ITERATIONS, THR_BOUND | THR_DETACHED) == -1) ACE_OS::perror ("ACE_Thread_Manager::spawn_n"); ACE_Thread_Manager::instance ()->wait (); #else - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "threads are not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ ACE_END_TEST; diff --git a/tests/Thread_Pool_Test.cpp b/tests/Thread_Pool_Test.cpp index 36c81d09d23..eea0bb607ef 100644 --- a/tests/Thread_Pool_Test.cpp +++ b/tests/Thread_Pool_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Thread_Pool_Test.cpp // @@ -19,7 +19,7 @@ // // = AUTHOR // Karlheinz Dorn, Doug Schmidt, and Prashant Jain -// +// // ============================================================================ #include "ace/Task.h" @@ -37,7 +37,7 @@ class Thread_Pool : public ACE_Task<ACE_MT_SYNCH> public: Thread_Pool (int n_threads); // Create the thread pool containing <n_threads>. - + ~Thread_Pool (void); virtual int open (void * = 0); @@ -64,34 +64,34 @@ Thread_Pool::~Thread_Pool (void) { } -int -Thread_Pool::close (u_long) -{ +int +Thread_Pool::close (u_long) +{ ACE_DEBUG ((LM_DEBUG, "(%t) close of worker\n")); return 0; } -Thread_Pool::Thread_Pool (int n_threads) +Thread_Pool::Thread_Pool (int n_threads) { // Create a pool of worker threads. if (this->activate (THR_NEW_LWP, n_threads) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); } - + // Simply enqueue the Message_Block into the end of the queue. int Thread_Pool::put (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - return this->putq (mb, tv); +{ + return this->putq (mb, tv); } // Iterate <n_iterations> printing off a message and "waiting" for all // other threads to complete this iteration. -int -Thread_Pool::svc (void) -{ +int +Thread_Pool::svc (void) +{ ACE_NEW_THREAD; // The <ACE_Task::svc_run()> method automatically adds us to the // <ACE_Service_Config>'s <ACE_Thread_Manager> when the thread @@ -101,7 +101,7 @@ Thread_Pool::svc (void) // message with a length == 0, which signals us to quit. for (int count = 1; ; count++) - { + { ACE_Message_Block *mb; ACE_ASSERT (this->getq (mb) != -1); @@ -109,7 +109,7 @@ Thread_Pool::svc (void) int length = mb->length (); if (length > 0) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d, queue len = %d, length = %d, text = \"%*s\"\n", count, this->msg_queue ()->message_count (), length, length - 1, mb->rd_ptr ())); @@ -119,7 +119,7 @@ Thread_Pool::svc (void) if (length == 0) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d, queue len = %d, got NULL message, exiting\n", count, this->msg_queue ()->message_count ())); break; @@ -134,7 +134,7 @@ Thread_Pool::svc (void) int Thread_Pool::open (void *) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) producer start, dumping the Thread_Pool\n")); this->dump (); @@ -143,8 +143,8 @@ Thread_Pool::open (void *) ACE_Message_Block *mb = 0; // Allocate a new message. - ACE_NEW_RETURN (mb, - ACE_Message_Block (BUFSIZ, ACE_Message_Block::MB_DATA, + ACE_NEW_RETURN (mb, + ACE_Message_Block (BUFSIZ, ACE_Message_Block::MB_DATA, 0, 0, 0, &this->lock_adapter_), -1); @@ -164,22 +164,22 @@ Thread_Pool::open (void *) } // Send a shutdown message to the waiting threads and exit. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "\n(%t) sending shutdown message to %d threads, dump of task:\n", this->thr_count ())); this->dump (); ACE_Message_Block *mb = 0; - ACE_NEW_RETURN (mb, - ACE_Message_Block (0, ACE_Message_Block::MB_DATA, + ACE_NEW_RETURN (mb, + ACE_Message_Block (0, ACE_Message_Block::MB_DATA, 0, 0, 0, &this->lock_adapter_), -1); for (int i = this->thr_count (); i > 0; i--) { - ACE_DEBUG ((LM_DEBUG, - "(%t) EOF, enqueueing NULL block for thread = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) EOF, enqueueing NULL block for thread = %d\n", i)); // Enqueue an empty message to flag each consumer to shutdown. @@ -199,20 +199,23 @@ Thread_Pool::open (void *) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Lock_Adapter<ACE_Thread_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Lock_Adapter<ACE_Thread_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ -int +int main (int, char *[]) { ACE_START_TEST ("Thread_Pool_Test"); #if defined (ACE_HAS_THREADS) int n_threads = ACE_MAX_THREADS; - + ACE_DEBUG ((LM_DEBUG, "(%t) threads = %d\n", n_threads)); // Create the worker tasks. @@ -229,7 +232,7 @@ main (int, char *[]) ACE_ASSERT (thread_pool.msg_queue ()->is_empty ()); ACE_DEBUG ((LM_DEBUG, "(%t) destroying worker tasks and exiting...\n")); - + #else ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ |