00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "w_defines.h"
00031
00032
00033
00034 #define SUBSTITUTE_MAIN
00035 #include "create_rec.cpp"
00036
00037 class smthread_user_t : public smthread_driver_t
00038 {
00039 rc_t do_work();
00040
00041 public:
00042 smthread_user_t(int ac, char **av)
00043 : smthread_driver_t(ac, av) {}
00044
00045 virtual ~smthread_user_t() { }
00046 w_rc_t vtable_locks() const;
00047 w_rc_t vtable_threads() const;
00048 w_rc_t vtable_xcts() const;
00049 };
00050
00051 rc_t
00052 smthread_user_t::do_work()
00053 {
00054 if (_initialize_device) W_DO(do_init());
00055 else W_DO(no_init());
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 W_DO(vtable_locks());
00067 W_DO(vtable_xcts());
00068 W_DO(vtable_threads());
00069 return RCOK;
00070 }
00071
00072 w_rc_t
00073 smthread_user_t::vtable_locks() const
00074 {
00075 vtable_t vt;
00076 W_DO(ss_m::lock_collect(vt));
00077 w_ostrstream o;
00078 vt.operator<<(o);
00079 fprintf(stderr, "Locks %s\n", o.c_str());
00080 return RCOK;
00081 }
00082
00083 w_rc_t
00084 smthread_user_t::vtable_xcts() const
00085 {
00086 vtable_t vt;
00087 W_DO(ss_m::xct_collect(vt));
00088 w_ostrstream o;
00089 vt.operator<<(o);
00090 fprintf(stderr, "Transactions %s\n", o.c_str());
00091 return RCOK;
00092 }
00093
00094 w_rc_t
00095 smthread_user_t::vtable_threads() const
00096 {
00097 vtable_t vt;
00098 W_DO(ss_m::thread_collect(vt));
00099 w_ostrstream o;
00100 vt.operator<<(o);
00101 fprintf(stderr, "Transactions %s\n", o.c_str());
00102 return RCOK;
00103 }
00104
00105 int
00106 main(int argc, char* argv[])
00107 {
00108 argv0 = argv[0];
00109
00110 smthread_user_t *smtu = new smthread_user_t(argc, argv);
00111 if (!smtu)
00112 W_FATAL(fcOUTOFMEMORY);
00113
00114 w_rc_t e = smtu->fork();
00115 if(e.is_error()) {
00116 cerr << "error forking thread: " << e <<endl;
00117 return 1;
00118 }
00119 e = smtu->join();
00120 if(e.is_error()) {
00121 cerr << "error forking thread: " << e <<endl;
00122 return 1;
00123 }
00124
00125 int rv = smtu->return_value();
00126 delete smtu;
00127
00128 return rv;
00129 }
00130