Browse Source

Move console lock and unlock functions (which also handle thread cancelstate) to miner.h

Luke Dashjr 12 years ago
parent
commit
d90dd0154a
2 changed files with 25 additions and 15 deletions
  1. 5 15
      miner.c
  2. 20 0
      miner.h

+ 5 - 15
miner.c

@@ -2199,22 +2199,12 @@ struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
 #endif
 struct cgpu_info *cpus;
 
-#ifdef HAVE_CURSES
-static bool _curses_cancel_disabled;
-static int _curses_prev_cancelstate;
-
-static inline void unlock_curses(void)
-{
-	mutex_unlock(&console_lock);
-	if (_curses_cancel_disabled)
-		pthread_setcancelstate(_curses_prev_cancelstate, &_curses_prev_cancelstate);
-}
+bool _bfg_console_cancel_disabled;
+int _bfg_console_prev_cancelstate;
 
-static inline void lock_curses(void)
-{
-	_curses_cancel_disabled = !pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &_curses_prev_cancelstate);
-	mutex_lock(&console_lock);
-}
+#ifdef HAVE_CURSES
+#define   lock_curses()  bfg_console_lock()
+#define unlock_curses()  bfg_console_unlock()
 
 static bool curses_active_locked(void)
 {

+ 20 - 0
miner.h

@@ -905,6 +905,26 @@ extern cglock_t ch_lock;
 extern pthread_rwlock_t mining_thr_lock;
 extern pthread_rwlock_t devices_lock;
 
+
+extern bool _bfg_console_cancel_disabled;
+extern int _bfg_console_prev_cancelstate;
+
+static inline
+void bfg_console_lock(void)
+{
+	_bfg_console_cancel_disabled = !pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &_bfg_console_prev_cancelstate);
+	mutex_lock(&console_lock);
+}
+
+static inline
+void bfg_console_unlock(void)
+{
+	mutex_unlock(&console_lock);
+	if (_bfg_console_cancel_disabled)
+		pthread_setcancelstate(_bfg_console_prev_cancelstate, &_bfg_console_prev_cancelstate);
+}
+
+
 extern void thread_reportin(struct thr_info *thr);
 extern void thread_reportout(struct thr_info *);
 extern void clear_stratum_shares(struct pool *pool);