aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ito.cpp6
-rw-r--r--src/ito.h20
-rw-r--r--src/itoserver.cpp10
-rw-r--r--src/itoserver.h8
-rw-r--r--src/tests/itoheap.cpp4
-rw-r--r--src/tests/itoqueue1.cpp8
-rw-r--r--src/tests/itoqueue2.cpp8
-rw-r--r--src/tests/socketblock.cpp4
8 files changed, 27 insertions, 41 deletions
diff --git a/src/ito.cpp b/src/ito.cpp
index dba1a87..0218ecc 100644
--- a/src/ito.cpp
+++ b/src/ito.cpp
@@ -32,9 +32,9 @@ bool Bu::Ito::stop()
32 32
33void *Bu::Ito::threadRunner( void *pThread ) 33void *Bu::Ito::threadRunner( void *pThread )
34{ 34{
35 void *pRet = ((Ito *)pThread)->run(); 35 ((Ito *)pThread)->run();
36 pthread_exit( pRet ); 36 pthread_exit( NULL );
37 return pRet; 37 return NULL;
38} 38}
39 39
40bool Bu::Ito::join() 40bool Bu::Ito::join()
diff --git a/src/ito.h b/src/ito.h
index 895ff47..a60a23d 100644
--- a/src/ito.h
+++ b/src/ito.h
@@ -61,16 +61,6 @@ namespace Bu
61 bool stop(); 61 bool stop();
62 62
63 /** 63 /**
64 * The workhorse of the Ito class. This is the function that will run
65 * in the thread, when this function exits the thread dies and is
66 * cleaned up by the system. Make sure to read up on ItoMutex,
67 * ItoCondition, and cancel to see how to control and protect
68 * everything you do in a safe way within this function.
69 *@returns I'm not sure right now, but this is the posix standard form.
70 */
71 virtual void *run()=0;
72
73 /**
74 * Join the thread in action. This function performs what is commonly 64 * Join the thread in action. This function performs what is commonly
75 * called a thread join. That is that it effectively makes the calling 65 * called a thread join. That is that it effectively makes the calling
76 * thread an the Ito thread contained in the called object one in the 66 * thread an the Ito thread contained in the called object one in the
@@ -89,6 +79,16 @@ namespace Bu
89 79
90 protected: 80 protected:
91 /** 81 /**
82 * The workhorse of the Ito class. This is the function that will run
83 * in the thread, when this function exits the thread dies and is
84 * cleaned up by the system. Make sure to read up on ItoMutex,
85 * ItoCondition, and cancel to see how to control and protect
86 * everything you do in a safe way within this function.
87 *@returns I'm not sure right now, but this is the posix standard form.
88 */
89 virtual void run()=0;
90
91 /**
92 * This is the hidden-heard of the thread system. While run is what the 92 * This is the hidden-heard of the thread system. While run is what the
93 * user gets to override, and everything said about it is true, this is 93 * user gets to override, and everything said about it is true, this is
94 * the function that actually makes up the thread, it simply calls the 94 * the function that actually makes up the thread, it simply calls the
diff --git a/src/itoserver.cpp b/src/itoserver.cpp
index 0640aad..279310d 100644
--- a/src/itoserver.cpp
+++ b/src/itoserver.cpp
@@ -74,7 +74,7 @@ void Bu::ItoServer::addClient( int nSocket, int nPort )
74 pC->start(); 74 pC->start();
75} 75}
76 76
77void *Bu::ItoServer::run() 77void Bu::ItoServer::run()
78{ 78{
79 for(;;) 79 for(;;)
80 { 80 {
@@ -105,8 +105,6 @@ void *Bu::ItoServer::run()
105 delete pCli; 105 delete pCli;
106 } 106 }
107 } 107 }
108
109 return NULL;
110} 108}
111 109
112void Bu::ItoServer::clientCleanup( int iSocket ) 110void Bu::ItoServer::clientCleanup( int iSocket )
@@ -138,7 +136,7 @@ Bu::ItoServer::ItoClient::~ItoClient()
138{ 136{
139} 137}
140 138
141void *Bu::ItoServer::ItoClient::run() 139void Bu::ItoServer::ItoClient::run()
142{ 140{
143 imProto.lock(); 141 imProto.lock();
144 rSrv.onNewConnection( pClient, iPort ); 142 rSrv.onNewConnection( pClient, iPort );
@@ -186,7 +184,7 @@ void *Bu::ItoServer::ItoClient::run()
186 184
187 rSrv.clientCleanup( iSocket ); 185 rSrv.clientCleanup( iSocket );
188 186
189 return NULL; 187 return;
190 } 188 }
191 } 189 }
192 190
@@ -197,8 +195,6 @@ void *Bu::ItoServer::ItoClient::run()
197 imProto.unlock(); 195 imProto.unlock();
198 } 196 }
199 } 197 }
200
201 return NULL;
202} 198}
203 199
204Bu::ItoServer::SrvClientLink::SrvClientLink( ItoClient *pClient ) : 200Bu::ItoServer::SrvClientLink::SrvClientLink( ItoClient *pClient ) :
diff --git a/src/itoserver.h b/src/itoserver.h
index 1b45748..c08d453 100644
--- a/src/itoserver.h
+++ b/src/itoserver.h
@@ -69,7 +69,8 @@ namespace Bu
69 virtual void onNewConnection( Client *pClient, int nPort )=0; 69 virtual void onNewConnection( Client *pClient, int nPort )=0;
70 virtual void onClosedConnection( Client *pClient )=0; 70 virtual void onClosedConnection( Client *pClient )=0;
71 71
72 virtual void *run(); 72 protected:
73 virtual void run();
73 74
74 private: 75 private:
75 class SrvClientLink; 76 class SrvClientLink;
@@ -81,11 +82,12 @@ namespace Bu
81 int nTimeoutSec, int nTimeoutUSec ); 82 int nTimeoutSec, int nTimeoutUSec );
82 virtual ~ItoClient(); 83 virtual ~ItoClient();
83 84
84 virtual void *run();
85
86 typedef ItoQueue<Bu::FString *> StringQueue; 85 typedef ItoQueue<Bu::FString *> StringQueue;
87 StringQueue qMsg; 86 StringQueue qMsg;
88 87
88 protected:
89 virtual void run();
90
89 private: 91 private:
90 ItoServer &rSrv; 92 ItoServer &rSrv;
91 Client *pClient; 93 Client *pClient;
diff --git a/src/tests/itoheap.cpp b/src/tests/itoheap.cpp
index 92bf3cf..347f1e0 100644
--- a/src/tests/itoheap.cpp
+++ b/src/tests/itoheap.cpp
@@ -23,7 +23,7 @@ public:
23 { 23 {
24 } 24 }
25 25
26 void *run() 26 void run()
27 { 27 {
28 for( int j = 0; j < 10; j++ ) 28 for( int j = 0; j < 10; j++ )
29 { 29 {
@@ -39,8 +39,6 @@ public:
39 printf("Nothing yet...\n"); 39 printf("Nothing yet...\n");
40 } 40 }
41 } 41 }
42
43 return NULL;
44 } 42 }
45 43
46 Bu::ItoHeap<int> hInt; 44 Bu::ItoHeap<int> hInt;
diff --git a/src/tests/itoqueue1.cpp b/src/tests/itoqueue1.cpp
index 815216d..a034c87 100644
--- a/src/tests/itoqueue1.cpp
+++ b/src/tests/itoqueue1.cpp
@@ -19,7 +19,7 @@ public:
19 { 19 {
20 } 20 }
21 21
22 void *run() 22 void run()
23 { 23 {
24 for( int i = 0; i < 10; i++ ) 24 for( int i = 0; i < 10; i++ )
25 { 25 {
@@ -35,8 +35,6 @@ public:
35 } 35 }
36 usleep( (int)(((double)rand())/((double)RAND_MAX)*2000000.0) ); 36 usleep( (int)(((double)rand())/((double)RAND_MAX)*2000000.0) );
37 } 37 }
38
39 return NULL;
40 } 38 }
41 39
42private: 40private:
@@ -54,7 +52,7 @@ public:
54 { 52 {
55 } 53 }
56 54
57 void *run() 55 void run()
58 { 56 {
59 for( int i = 0; i < 11; i++ ) 57 for( int i = 0; i < 11; i++ )
60 { 58 {
@@ -62,8 +60,6 @@ public:
62 q.enqueue( new std::string( strbase ) ); 60 q.enqueue( new std::string( strbase ) );
63 printf("[%d] write: %s\n", id, strbase ); 61 printf("[%d] write: %s\n", id, strbase );
64 } 62 }
65
66 return NULL;
67 } 63 }
68 64
69private: 65private:
diff --git a/src/tests/itoqueue2.cpp b/src/tests/itoqueue2.cpp
index d1f20a4..b11aa32 100644
--- a/src/tests/itoqueue2.cpp
+++ b/src/tests/itoqueue2.cpp
@@ -19,7 +19,7 @@ public:
19 { 19 {
20 } 20 }
21 21
22 void *run() 22 void run()
23 { 23 {
24 for( int i = 0; i < 10; i++ ) 24 for( int i = 0; i < 10; i++ )
25 { 25 {
@@ -35,8 +35,6 @@ public:
35 delete pStr; 35 delete pStr;
36 } 36 }
37 } 37 }
38
39 return NULL;
40 } 38 }
41 39
42private: 40private:
@@ -54,7 +52,7 @@ public:
54 { 52 {
55 } 53 }
56 54
57 void *run() 55 void run()
58 { 56 {
59 for( int i = 0; i < 11; i++ ) 57 for( int i = 0; i < 11; i++ )
60 { 58 {
@@ -62,8 +60,6 @@ public:
62 printf("[%d] write: %s\n", id, strbase ); 60 printf("[%d] write: %s\n", id, strbase );
63 q.enqueue( new std::string( strbase ) ); 61 q.enqueue( new std::string( strbase ) );
64 } 62 }
65
66 return NULL;
67 } 63 }
68 64
69private: 65private:
diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp
index 3d50aa0..a1ea18d 100644
--- a/src/tests/socketblock.cpp
+++ b/src/tests/socketblock.cpp
@@ -19,7 +19,7 @@ public:
19 { 19 {
20 } 20 }
21 21
22 virtual void *run() 22 virtual void run()
23 { 23 {
24 Bu::Socket c = s.accept( 45, 0 ); 24 Bu::Socket c = s.accept( 45, 0 );
25 printf("TstServer: Accetped connection.\n"); fflush( stdout ); 25 printf("TstServer: Accetped connection.\n"); fflush( stdout );
@@ -33,8 +33,6 @@ public:
33 33
34 printf("TstServer: Closing connection...\n"); fflush( stdout ); 34 printf("TstServer: Closing connection...\n"); fflush( stdout );
35 c.close(); 35 c.close();
36
37 return NULL;
38 } 36 }
39 37
40 Bu::ServerSocket s; 38 Bu::ServerSocket s;