remove some unused code

This commit is contained in:
云风
2013-09-04 10:49:48 +08:00
parent 8b4cd92ae5
commit 25a1f17a16

View File

@@ -43,10 +43,8 @@ create_thread(pthread_t *thread, void *(*start_routine) (void *), void *arg) {
static void static void
wakeup(struct monitor *m, int busy) { wakeup(struct monitor *m, int busy) {
if (m->sleep >= m->count - busy) { if (m->sleep >= m->count - busy) {
if (pthread_mutex_lock(&m->mutex) == 0) { // signal sleep worker, "spurious wakeup" is harmless
pthread_cond_signal(&m->cond); pthread_cond_signal(&m->cond);
pthread_mutex_unlock(&m->mutex);
}
} }
} }
@@ -59,7 +57,6 @@ _socket(void *p) {
break; break;
if (r<0) if (r<0)
continue; continue;
// FIXME: wakeup will kill some performance when lots of connections
wakeup(m,0); wakeup(m,0);
} }
return NULL; return NULL;
@@ -109,9 +106,14 @@ _worker(void *p) {
CHECK_ABORT CHECK_ABORT
if (pthread_mutex_lock(&m->mutex) == 0) { if (pthread_mutex_lock(&m->mutex) == 0) {
++ m->sleep; ++ m->sleep;
// "spurious wakeup" is harmless,
// because skynet_context_message_dispatch() can be call at any time.
pthread_cond_wait(&m->cond, &m->mutex); pthread_cond_wait(&m->cond, &m->mutex);
-- m->sleep; -- m->sleep;
pthread_mutex_unlock(&m->mutex); if (pthread_mutex_unlock(&m->mutex)) {
fprintf(stderr, "unlock mutex error");
exit(1);
}
} }
} }
} }