summaryrefslogtreecommitdiff
path: root/netsvcs/clients/Tokens/collection
diff options
context:
space:
mode:
Diffstat (limited to 'netsvcs/clients/Tokens/collection')
-rw-r--r--netsvcs/clients/Tokens/collection/Makefile109
-rw-r--r--netsvcs/clients/Tokens/collection/README25
-rw-r--r--netsvcs/clients/Tokens/collection/collection.cpp211
-rw-r--r--netsvcs/clients/Tokens/collection/rw_locks.cpp175
4 files changed, 0 insertions, 520 deletions
diff --git a/netsvcs/clients/Tokens/collection/Makefile b/netsvcs/clients/Tokens/collection/Makefile
deleted file mode 100644
index f563bb9187e..00000000000
--- a/netsvcs/clients/Tokens/collection/Makefile
+++ /dev/null
@@ -1,109 +0,0 @@
-#----------------------------------------------------------------------------
-# @(#)Makefile 1.1 10/18/96
-#
-# Makefile for repeating token client application
-#----------------------------------------------------------------------------
-
-#----------------------------------------------------------------------------
-# Local macros
-#----------------------------------------------------------------------------
-
-BIN = collection
-
-FILES = collection
-
-LSRC = $(addsuffix .cpp,$(FILES))
-LOBJ = $(LSRC:%.cpp=$(VDIR)%.o)
-SHOBJ = $(addsuffix .so,$(FILES))
-
-BUILD = $(VBIN)
-
-#----------------------------------------------------------------------------
-# Include macros and targets
-#----------------------------------------------------------------------------
-
-include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU
-include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU
-include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU
-include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU
-include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU
-include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU
-include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU
-
-#----------------------------------------------------------------------------
-# Local targets
-#----------------------------------------------------------------------------
-
-#----------------------------------------------------------------------------
-# Dependencies
-#----------------------------------------------------------------------------
-
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
-# DO NOT DELETE THIS LINE -- g++dep uses it.
-# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-
-.obj/collection.o .shobj/collection.so: collection.cpp \
- $(WRAPPER_ROOT)/ace/OS.h \
- $(WRAPPER_ROOT)/ace/Time_Value.h \
- $(WRAPPER_ROOT)/ace/config.h \
- $(WRAPPER_ROOT)/ace/stdcpp.h \
- $(WRAPPER_ROOT)/ace/Trace.h \
- $(WRAPPER_ROOT)/ace/Log_Msg.h \
- $(WRAPPER_ROOT)/ace/Log_Record.h \
- $(WRAPPER_ROOT)/ace/Log_Priority.h \
- $(WRAPPER_ROOT)/ace/ACE.h \
- $(WRAPPER_ROOT)/ace/ACE.i \
- $(WRAPPER_ROOT)/ace/Log_Record.i \
- $(WRAPPER_ROOT)/ace/Get_Opt.h \
- $(WRAPPER_ROOT)/ace/Local_Tokens.h \
- $(WRAPPER_ROOT)/ace/Synch.h \
- $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
- $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
- $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
- $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
- $(WRAPPER_ROOT)/ace/Synch_T.h \
- $(WRAPPER_ROOT)/ace/Event_Handler.h \
- $(WRAPPER_ROOT)/ace/Stack.h \
- $(WRAPPER_ROOT)/ace/Synch_Options.h \
- $(WRAPPER_ROOT)/ace/Map_Manager.h \
- $(WRAPPER_ROOT)/ace/Token_Collection.h \
- $(WRAPPER_ROOT)/ace/SString.h \
- $(WRAPPER_ROOT)/ace/Remote_Tokens.h \
- $(WRAPPER_ROOT)/ace/INET_Addr.h \
- $(WRAPPER_ROOT)/ace/Addr.h \
- $(WRAPPER_ROOT)/ace/SOCK_Connector.h \
- $(WRAPPER_ROOT)/ace/SOCK_Stream.h \
- $(WRAPPER_ROOT)/ace/SOCK_IO.h \
- $(WRAPPER_ROOT)/ace/SOCK.h \
- $(WRAPPER_ROOT)/ace/IPC_SAP.h \
- $(WRAPPER_ROOT)/ace/IPC_SAP.i \
- $(WRAPPER_ROOT)/ace/SOCK.i \
- $(WRAPPER_ROOT)/ace/SOCK_IO.i \
- $(WRAPPER_ROOT)/ace/SOCK_Stream.i \
- $(WRAPPER_ROOT)/ace/SOCK_Connector.i \
- $(WRAPPER_ROOT)/ace/Token_Request_Reply.h \
- $(WRAPPER_ROOT)/ace/Thread_Manager.h \
- $(WRAPPER_ROOT)/ace/Thread.h \
- $(WRAPPER_ROOT)/ace/Service_Config.h \
- $(WRAPPER_ROOT)/ace/Service_Object.h \
- $(WRAPPER_ROOT)/ace/Shared_Object.h \
- $(WRAPPER_ROOT)/ace/Set.h \
- $(WRAPPER_ROOT)/ace/Proactor.h \
- $(WRAPPER_ROOT)/ace/Message_Block.h \
- $(WRAPPER_ROOT)/ace/Malloc.h \
- $(WRAPPER_ROOT)/ace/Malloc_T.h \
- $(WRAPPER_ROOT)/ace/Memory_Pool.h \
- $(WRAPPER_ROOT)/ace/Signal.h \
- $(WRAPPER_ROOT)/ace/Mem_Map.h \
- $(WRAPPER_ROOT)/ace/Timer_Queue.h \
- $(WRAPPER_ROOT)/ace/Timer_Queue.i \
- $(WRAPPER_ROOT)/ace/ReactorEx.h \
- $(WRAPPER_ROOT)/ace/Token.h \
- $(WRAPPER_ROOT)/ace/Reactor.h \
- $(WRAPPER_ROOT)/ace/Handle_Set.h \
- $(WRAPPER_ROOT)/ace/Pipe.h \
- $(WRAPPER_ROOT)/ace/Pipe.i \
- $(WRAPPER_ROOT)/ace/Reactor.i \
- $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h
-
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/netsvcs/clients/Tokens/collection/README b/netsvcs/clients/Tokens/collection/README
deleted file mode 100644
index 4c25a1f729e..00000000000
--- a/netsvcs/clients/Tokens/collection/README
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Shows how applications can use the ACE_Token_Collection utility. This
-example creates three collections and spawns a thread to operate on
-each. The threads use the collective acquire, renew, and release
-features of ACE_Token_Collection.
-
-Here are the command-line parameters for collection:
-
-./collection:
-[-h <remote host>]
-[-p <remote port>]
-[-n <iterations>]
-[-d debug]
-
-To run the collection locally with debugging info, type
-
-% ./collection -d
-
-To run the collection remotely with debugging info, first start a
-token server and the type:
-
-% ./collection -d -h <token-server-host> -p <token-server-port>
-
-The -n <iterations> option is to control how often each thread
-iterates on the acquire, renew, release cycle.
diff --git a/netsvcs/clients/Tokens/collection/collection.cpp b/netsvcs/clients/Tokens/collection/collection.cpp
deleted file mode 100644
index e3dc18d8008..00000000000
--- a/netsvcs/clients/Tokens/collection/collection.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-// ============================================================================
-// $Id$
-
-//
-// = LIBRARY
-// examples
-//
-// = FILENAME
-// collection.cpp
-//
-// = DESCRIPTION
-// Shows how applications can use the ACE_Token_Collection
-// utility. This example creates three collections and spawns a
-// thread to operate on each. The threads use the collective
-// acquire, renew, and release features of ACE_Token_Collection.
-//
-// = AUTHOR
-// Tim Harrison
-//
-// ============================================================================
-
-#include "ace/OS.h"
-
-#include "ace/Get_Opt.h"
-#include "ace/Local_Tokens.h"
-#include "ace/Token_Collection.h"
-#include "ace/Remote_Tokens.h"
-#include "ace/Thread_Manager.h"
-#include "ace/Service_Config.h"
-
-#if defined (ACE_HAS_THREADS)
-
-static char *server_host = ACE_DEFAULT_SERVER_HOST;
-static int server_port = ACE_DEFAULT_SERVER_PORT;
-static int threads = 2;
-static int iterations = 50;
-static int debug = 0;
-static int remote = 0;
-static int tokens = 5;
-
-static void *
-run_thread (void *vp)
-{
- ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ());
- ACE_Token_Proxy *collection = (ACE_Token_Proxy *) vp;
-
- int count = iterations;
- while (count--)
- {
- if (collection->acquire () == -1)
- {
- if (ACE_OS::last_error () == EDEADLK)
- {
- ACE_DEBUG ((LM_DEBUG, "deadlock detected in acquire"));
- continue;
- }
- ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","run_thread"));
- return (void *) -1;
- }
-
- ACE_DEBUG ((LM_DEBUG, "(%t) %s acquired.\n", collection->name ()));
-
- if (collection->renew () == -1)
- {
- if (ACE_OS::last_error () == EDEADLK)
- {
- ACE_DEBUG ((LM_DEBUG, "deadlock detected"));
- goto deadlock;
- }
- ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","run_thread"));
- return (void *) -1;
- }
-
- ACE_DEBUG ((LM_DEBUG, "(%t) %s renewed.\n", collection->name ()));
-
- deadlock:
- if (collection->release () == -1)
- {
- ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","run_thread"));
- return (void *) -1;
- }
-
- ACE_DEBUG ((LM_DEBUG, "(%t) %s released.\n", collection->name ()));
- }
-
-
- ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n"));
- return 0;
-}
-
-static int
-parse_args (int argc, char *argv[])
-{
- ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE);
-
- ACE_Get_Opt get_opt (argc, argv, "un:dp:h:", 1);
-
- for (int c; (c = get_opt ()) != -1; )
- {
- switch (c)
- {
- case 'h': // specify the host machine on which the server is running
- server_host = get_opt.optarg;
- remote = 1;
- break;
- case 'p': // specify the port on which the server is running
- server_port = ACE_OS::atoi (get_opt.optarg);
- remote = 1;
- break;
- case 'd':
- debug = 1;
- break;
- case 'n':
- iterations = ACE_OS::atoi (get_opt.optarg);
- break;
- case 'u':
- // usage: fallthrough
- default:
- ACE_ERROR_RETURN ((LM_ERROR,
- "%n:\n"
- "[-h <remote host>]\n"
- "[-p <remote port>]\n"
- "[-n <iterations>]\n"
- "[-d debug]\n", 1), -1);
- break;
- }
- }
-
- return 0;
-}
-
-int
-main (int argc, char* argv[])
-{
- if (parse_args (argc, argv) == -1)
- return -1;
-
- ACE_Token_Proxy *A; // Mutex *A*.
- ACE_Token_Proxy *B; // Mutex *B*.
- ACE_Token_Proxy *R; // *R*eader Lock.
- ACE_Token_Proxy *W; // *W*riter Lock.
-
- // Depending on the command line arguments, we will create local or
- // remote tokens. The names of the tokens are not important as long
- // as they are unique.
- if (remote)
- {
- ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host));
- A = new ACE_Remote_Mutex ("R Mutex A", 0, debug);
- B = new ACE_Remote_Mutex ("R Mutex B", 0, debug);
- R = new ACE_Remote_RLock ("R Reader Lock", 0, debug);
- W = new ACE_Remote_WLock ("R Writer Lock", 0, debug);
- }
- else
- {
- A = new ACE_Local_Mutex ("L Mutex A", 0, debug);
- B = new ACE_Local_Mutex ("L Mutex B", 0, debug);
- R = new ACE_Local_RLock ("L Reader Lock", 0, debug);
- W = new ACE_Local_WLock ("L Writer Lock", 0, debug);
- }
-
- // These collections will be treated as Tokens by the threads.
- ACE_Token_Collection collectionAR (debug, "A and Reader");
- ACE_Token_Collection collectionAW (debug, "A and Writer");
- ACE_Token_Collection collectionBR (debug, "B and Reader");
-
- // AR and BR can run concurrently. Neither AR or BR can run when AW
- // is running.
- collectionAR.insert (*A);
- collectionAR.insert (*R);
-
- collectionAW.insert (*A);
- collectionAW.insert (*W);
-
- collectionBR.insert (*B);
- collectionBR.insert (*R);
-
- // Spawn off three threads.
- ACE_Thread_Manager *mgr = ACE_Service_Config::thr_mgr ();
-
- if (mgr->spawn (ACE_THR_FUNC (run_thread),
- (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1)
- ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1);
-
- if (mgr->spawn (ACE_THR_FUNC (run_thread),
- (void *) &collectionAW, THR_BOUND | THR_SUSPENDED) == -1)
- ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1);
-
- if (mgr->spawn (ACE_THR_FUNC (run_thread),
- (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1)
- ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1);
-
-#if ! defined (ACE_HAS_PTHREADS)
- if (mgr->resume_all () == -1)
- ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1);
-#endif
-
- // Wait for all threads to exit.
- mgr->wait ();
-
- return 42;
-}
-
-#else
-int
-main (int, char *[])
-{
- ACE_ERROR_RETURN ((LM_ERROR,
- "threads not supported on this platform\n"), -1);
-}
-#endif /* ACE_HAS_THREADS */
diff --git a/netsvcs/clients/Tokens/collection/rw_locks.cpp b/netsvcs/clients/Tokens/collection/rw_locks.cpp
deleted file mode 100644
index 89ca35f1a9b..00000000000
--- a/netsvcs/clients/Tokens/collection/rw_locks.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-#include "ace/OS.h"
-// $Id$
-
-
-#include "ace/Get_Opt.h"
-#include "ace/Local_Tokens.h"
-#include "ace/Remote_Tokens.h"
-#include "ace/Thread_Manager.h"
-
-#if defined (ACE_HAS_THREADS)
-
-static ACE_Token_Proxy *global_rlock;
-static ACE_Token_Proxy *global_wlock;
-
-static char *server_host = ACE_DEFAULT_SERVER_HOST;
-static int server_port = ACE_DEFAULT_SERVER_PORT;
-static int ignore_deadlock = 0;
-static int threads = 2;
-static int iterations = 50;
-static int debug = 0;
-static int remote = 0;
-static int reads = 4;
-static int write_sleep = 0;
-
-static void *
-run_thread (void *vp)
-{
- ACE_Thread_Manager *thr_mgr = (ACE_Thread_Manager*) vp;
- ACE_Thread_Control tc (thr_mgr);
-
- for (int x = 0; x < iterations; x++)
- {
- int y = 0;
- for (; y < reads; y++)
- {
- if (global_rlock->acquire () == -1)
- {
- if (ACE_Log_Msg::instance ()->errnum () == EDEADLK)
- {
- ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected\n"));
- goto READ_DEADLOCK;
- }
- else return 0;
- }
-
- ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n"));
- }
-
- READ_DEADLOCK:
-
- for (; y > 0; y--)
- {
- if (global_rlock->release () == 0)
- ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n"));
- }
-
- if (global_wlock->acquire () == -1)
- {
- ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected\n"));
- }
- else
- {
- if (write_sleep)
- ACE_OS::sleep (1);
- ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n"));
- if (global_wlock->release () == 0)
- ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n"));
- }
- }
-
- ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n"));
- return 0;
-}
-
-static int
-parse_args (int argc, char *argv[])
-{
- ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE);
-
- ACE_Get_Opt get_opt (argc, argv, "t:iun:drR:sp:h:", 1);
-
- for (int c; (c = get_opt ()) != -1; )
- {
- switch (c)
- {
- case 'h': // specify the host machine on which the server is running
- server_host = get_opt.optarg;
- break;
- case 'p': // specify the port on which the server is running
- server_port = ACE_OS::atoi (get_opt.optarg);
- break;
- case 't':
- threads = ACE_OS::atoi (get_opt.optarg);
- break;
- case 'R':
- reads = ACE_OS::atoi (get_opt.optarg);
- break;
- case 'd':
- debug = 1;
- break;
- case 'r':
- remote = 1;
- break;
- case 's':
- write_sleep = 1;
- break;
- case 'n':
- iterations = ACE_OS::atoi (get_opt.optarg);
- break;
- case 'i':
- ignore_deadlock = 1;
- break;
- case 'u':
- // usage: fallthrough
- default:
- ACE_ERROR_RETURN ((LM_ERROR,
- "%n:\n"
- "[-i ignore deadlock]\n"
- "[-n <iterations>]\n"
- "[-R <reads>]\n"
- "[-r use remote locks]\n"
- "[-d debug]\n"
- "[-s sleep during writes]\n"
- "[-t <threads>\n", 1), -1);
- break;
- }
- }
-
- return 0;
-}
-
-int
-main (int argc, char* argv[])
-{
- if (parse_args (argc, argv) == -1)
- return -1;
-
- if (remote)
- {
- ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host));
- global_rlock = (ACE_Token_Proxy *) new
- ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug);
- global_wlock = (ACE_Token_Proxy *) new
- ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug);
- }
- else
- {
- global_rlock = (ACE_Token_Proxy *) new
- ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug);
- global_wlock = (ACE_Token_Proxy *) new
- ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug);
- }
-
- ACE_Thread_Manager mgr;
-
- if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread),
- (void *) &mgr, THR_BOUND | THR_SUSPENDED) == -1)
- ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1);
-
- if (mgr.resume_all () == -1)
- ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1);
-
- mgr.wait ();
-
- return 42;
-}
-
-#else
-int
-main (int, char *[])
-{
- ACE_ERROR_RETURN ((LM_ERROR,
- "threads not supported on this platform\n"), -1);
-}
-#endif /* ACE_HAS_THREADS */