Changeset 5:6a3516d3ee5c in rrlib_thread


Ignore:
Timestamp:
20.07.2012 14:27:09 (7 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Rebase:
34303730656136653036633431313433363263626464336239386635383931623132666139396633
Message:

Adapted to changes in rrlib_logging

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • internal/tLockStack.cpp

    r4 r5  
    119119  if (!s) 
    120120  { 
    121     RRLIB_LOG_PRINT(eLL_USER, "Current thread has no lock stack (yet)."); 
     121    RRLIB_LOG_PRINT(USER, "Current thread has no lock stack (yet)."); 
    122122    return; 
    123123  } 
    124   RRLIB_LOG_PRINT(eLL_USER, "Lock Stack Dump:"); 
     124  RRLIB_LOG_PRINT(USER, "Lock Stack Dump:"); 
    125125  for (auto it = s->entries.rbegin(); it < s->entries.rend(); it++) 
    126126  { 
     
    128128    if (l->locked_ordered) 
    129129    { 
    130       RRLIB_LOG_PRINTF(eLL_USER, "  %s %p ('%s', primary %d, secondary %d)", l->locked_simple ? "OrderedMutex" : "RecursiveMutex", l->locked_ordered, l->locked_ordered->GetDescription(), l->locked_ordered->GetPrimary(), l->locked_ordered->GetSecondary()); 
     130      RRLIB_LOG_PRINTF(USER, "  %s %p ('%s', primary %d, secondary %d)", l->locked_simple ? "OrderedMutex" : "RecursiveMutex", l->locked_ordered, l->locked_ordered->GetDescription(), l->locked_ordered->GetPrimary(), l->locked_ordered->GetSecondary()); 
    131131    } 
    132132    else 
    133133    { 
    134       RRLIB_LOG_PRINTF(eLL_USER, "  Simple Mutex %p", l->locked_simple); 
     134      RRLIB_LOG_PRINTF(USER, "  Simple Mutex %p", l->locked_simple); 
    135135    } 
    136136  } 
     
    156156      if (lock->locked_ordered) 
    157157      { 
    158         RRLIB_LOG_PRINTF(eLL_ERROR, "Attempt failed to lock ordered mutex %p ('%s', primary %d, secondary %d). You are not allowed to lock another mutex after a simple one.", lock->locked_ordered, lock->locked_ordered->GetDescription(), lock->locked_ordered->GetPrimary(), lock->locked_ordered->GetSecondary()); 
     158        RRLIB_LOG_PRINTF(ERROR, "Attempt failed to lock ordered mutex %p ('%s', primary %d, secondary %d). You are not allowed to lock another mutex after a simple one.", lock->locked_ordered, lock->locked_ordered->GetDescription(), lock->locked_ordered->GetPrimary(), lock->locked_ordered->GetSecondary()); 
    159159      } 
    160160      else 
    161161      { 
    162         RRLIB_LOG_PRINTF(eLL_ERROR, "Attempt failed to lock simple mutex %p. You are not allowed to lock another mutex after a simple one.", lock->locked_simple); 
     162        RRLIB_LOG_PRINTF(ERROR, "Attempt failed to lock simple mutex %p. You are not allowed to lock another mutex after a simple one.", lock->locked_simple); 
    163163      } 
    164164      DumpStack(); 
     
    174174      if (!found) 
    175175      { 
    176         RRLIB_LOG_PRINTF(eLL_ERROR, "Attempt failed to lock ordered mutex %p ('%s', primary %d, secondary %d). Lock may not be acquired in this order.", lock->locked_ordered, lock->locked_ordered->GetDescription(), lock->locked_ordered->GetPrimary(), lock->locked_ordered->GetSecondary()); 
     176        RRLIB_LOG_PRINTF(ERROR, "Attempt failed to lock ordered mutex %p ('%s', primary %d, secondary %d). Lock may not be acquired in this order.", lock->locked_ordered, lock->locked_ordered->GetDescription(), lock->locked_ordered->GetPrimary(), lock->locked_ordered->GetSecondary()); 
    177177        DumpStack(); 
    178178        abort(); 
     
    186186        if (lock->locked_ordered == (*it)->locked_ordered) 
    187187        { 
    188           RRLIB_LOG_PRINTF(eLL_ERROR, "Attempt failed to lock ordered mutex %p ('%s', primary %d, secondary %d). Only recursive mutexes may be locked twice.", lock->locked_ordered, lock->locked_ordered->GetDescription(), lock->locked_ordered->GetPrimary(), lock->locked_ordered->GetSecondary()); 
     188          RRLIB_LOG_PRINTF(ERROR, "Attempt failed to lock ordered mutex %p ('%s', primary %d, secondary %d). Only recursive mutexes may be locked twice.", lock->locked_ordered, lock->locked_ordered->GetDescription(), lock->locked_ordered->GetPrimary(), lock->locked_ordered->GetSecondary()); 
    189189          DumpStack(); 
    190190          abort(); 
  • tConditionVariable.cpp

    r3 r5  
    111111          { 
    112112            // clock inconsistency 
    113             RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Detected clock inconsistency. New timestamp is more than ", 
     113            RRLIB_LOG_PRINT(DEBUG_WARNING, "Detected clock inconsistency. New timestamp is more than ", 
    114114                            rrlib::time::ToIsoString(wait_for - (*it)->waiting_for_application_duration), " in the past."); 
    115115            (*it)->waiting_for_application_duration = (*it)->waiting_for_application_duration / 2; 
    116             RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Recovering by waiting another ", rrlib::time::ToString((*it)->waiting_for_application_duration), " (half the original timeout)."); 
     116            RRLIB_LOG_PRINT(DEBUG_WARNING, "Recovering by waiting another ", rrlib::time::ToString((*it)->waiting_for_application_duration), " (half the original timeout)."); 
    117117 
    118118            (*it)->waiting_until_application_time = current_time - (*it)->waiting_for_application_duration; 
     
    281281      catch (const std::logic_error&) // tTimeMutex no longer exists 
    282282      { 
    283         RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Won't wait after rrlibs have been (partly) destructed."); 
     283        RRLIB_LOG_PRINT(DEBUG_WARNING, "Won't wait after rrlibs have been (partly) destructed."); 
    284284        return; 
    285285      } 
     
    333333      { 
    334334        // clock inconsistency 
    335         RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Detected clock inconsistency. New timestamp is more than ", 
     335        RRLIB_LOG_PRINT(DEBUG_WARNING, "Detected clock inconsistency. New timestamp is more than ", 
    336336                        rrlib::time::ToIsoString(waiting_for_application_duration_new - waiting_for_application_duration), " in the past."); 
    337337        waiting_for_application_duration = waiting_for_application_duration / 2; 
    338         RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Recovering by waiting another ", rrlib::time::ToString(waiting_for_application_duration), " (half the original timeout)."); 
     338        RRLIB_LOG_PRINT(DEBUG_WARNING, "Recovering by waiting another ", rrlib::time::ToString(waiting_for_application_duration), " (half the original timeout)."); 
    339339 
    340340        waiting_until_application_time = current_app_time - waiting_for_application_duration; 
  • tLoopThread.cpp

    r4 r5  
    112112      { 
    113113        //System.err.println("warning: Couldn't keep up cycle time (" + (-waitForX) + " ms too long)"); 
    114         RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Couldn't keep up cycle time (", rrlib::time::ToString(-wait_for_x), " too long)"); 
     114        RRLIB_LOG_PRINT(WARNING, "Couldn't keep up cycle time (", rrlib::time::ToString(-wait_for_x), " too long)"); 
    115115      } 
    116116      else if (wait_for_x > cycle_time) 
    117117      { 
    118         RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Clock inconsistency detected: Last cycle started \"after\" this cycle. This would mean we'd have to wait for ", rrlib::time::ToString(wait_for_x), " now."); 
     118        RRLIB_LOG_PRINT(WARNING, "Clock inconsistency detected: Last cycle started \"after\" this cycle. This would mean we'd have to wait for ", rrlib::time::ToString(wait_for_x), " now."); 
    119119        if (last_wait > rrlib::time::tDuration::zero()) 
    120120        { 
    121           RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Waiting for ", rrlib::time::ToString(last_wait), ", as in last cycle, instead."); 
     121          RRLIB_LOG_PRINT(WARNING, "Waiting for ", rrlib::time::ToString(last_wait), ", as in last cycle, instead."); 
    122122          Sleep(last_wait, local_use_application_time); 
    123123        } 
    124124        else 
    125125        { 
    126           RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Not waiting at all. As it appears, this thread has never waited yet."); 
     126          RRLIB_LOG_PRINT(WARNING, "Not waiting at all. As it appears, this thread has never waited yet."); 
    127127        } 
    128128      } 
     
    158158  catch (const std::exception& e) 
    159159  { 
    160     RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Uncaught Exception: ", e); 
     160    RRLIB_LOG_PRINT(DEBUG_WARNING, "Uncaught Exception: ", e); 
    161161  } 
    162162} 
  • tThread.cpp

    r4 r5  
    199199tThread::~tThread() 
    200200{ 
    201   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_1, "Deleting thread ", this); 
     201  RRLIB_LOG_PRINT(DEBUG_VERBOSE_1, "Deleting thread ", this); 
    202202 
    203203  // remove from thread list 
     
    246246 
    247247  //printf("Creating thread %p %s\n", this, getName().getCString()); 
    248   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_1, "Creating thread ", this); 
     248  RRLIB_LOG_PRINT(DEBUG_VERBOSE_1, "Creating thread ", this); 
    249249} 
    250250 
     
    271271  if (unknown_thread) 
    272272  { 
    273     RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Operation not supported for threads of unknown origin."); 
     273    RRLIB_LOG_PRINT(WARNING, "Operation not supported for threads of unknown origin."); 
    274274    return; 
    275275  } 
     
    280280  if (&CurrentThread() == this) 
    281281  { 
    282     RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Thread cannot join itself"); 
     282    RRLIB_LOG_PRINT(DEBUG_WARNING, "Thread cannot join itself"); 
    283283    return; 
    284284  } 
    285285  PreJoin(); 
    286   RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_VERBOSE_1, "Joining Thread"); 
     286  RRLIB_LOG_PRINT(DEBUG_VERBOSE_1, "Joining Thread"); 
    287287 
    288288  int joining = joining_threads.fetch_add(1); 
    289289  if (joining >= 1) 
    290290  { 
    291     RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_WARNING, "Multiple threads are trying to join. Returning this thread without joining."); 
     291    RRLIB_LOG_PRINT(DEBUG_WARNING, "Multiple threads are trying to join. Returning this thread without joining."); 
    292292    return; 
    293293  } 
     
    296296    wrapped_thread.join(); 
    297297  } 
    298   RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_VERBOSE_1, "Joined Thread"); 
     298  RRLIB_LOG_PRINT(DEBUG_VERBOSE_1, "Joined Thread"); 
    299299} 
    300300 
     
    306306void tThread::Launcher() 
    307307{ 
    308   //unsafe _FINROC_LOG_MESSAGE(eLL_DEBUG_VERBOSE_2, logDomain) << "Entering"; 
     308  //unsafe _FINROC_LOG_MESSAGE(DEBUG_VERBOSE_2, logDomain) << "Entering"; 
    309309  cur_thread = this; 
    310310  tLock l(*this); 
    311311  state = tState::PREPARE_RUNNING; 
    312   //unsafe _FINROC_LOG_MESSAGE(eLL_DEBUG_VERBOSE_2, logDomain) << "Locked"; 
     312  //unsafe _FINROC_LOG_MESSAGE(DEBUG_VERBOSE_2, logDomain) << "Locked"; 
    313313  //curThread = threadPtr; 
    314314  GetCurThreadLocal().reset(this); 
    315   //unsafe _FINROC_LOG_MESSAGE(eLL_DEBUG_VERBOSE_2, logDomain) << "ThreadLocal set"; 
     315  //unsafe _FINROC_LOG_MESSAGE(DEBUG_VERBOSE_2, logDomain) << "ThreadLocal set"; 
    316316 
    317317  // wait for start signal 
     
    328328    { 
    329329      l.Unlock(); 
    330       RRLIB_LOG_PRINT(eLL_DEBUG, "Thread started"); 
     330      RRLIB_LOG_PRINT(DEBUG, "Thread started"); 
    331331      Run(); 
    332       RRLIB_LOG_PRINT(eLL_DEBUG, "Thread exited normally"); 
     332      RRLIB_LOG_PRINT(DEBUG, "Thread exited normally"); 
    333333    } 
    334334    catch (const std::exception& e) 
    335335    { 
    336       RRLIB_LOG_PRINT(eLL_ERROR, "Thread exited because of exception: ", e.what()); 
    337     } 
    338   } 
    339  
    340   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Exiting"); 
     336      RRLIB_LOG_PRINT(ERROR, "Thread exited because of exception: ", e.what()); 
     337    } 
     338  } 
     339 
     340  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Exiting"); 
    341341 
    342342  l.Unlock(); 
     
    351351  catch (const std::exception& e) 
    352352  { 
    353     RRLIB_LOG_PRINT(eLL_ERROR, "Thread encountered exception during cleanup: ", e.what()); 
     353    RRLIB_LOG_PRINT(ERROR, "Thread encountered exception during cleanup: ", e.what()); 
    354354  } 
    355355} 
     
    363363void tThread::PreJoin() 
    364364{ 
    365   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Entering"); 
     365  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Entering"); 
    366366  tLock l(*this); 
    367   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Locked"); 
     367  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Locked"); 
    368368  if (state == tState::PREPARE_RUNNING || state == tState::NEW) 
    369369  { 
    370     RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Notifying"); 
     370    RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Notifying"); 
    371371    stop_signal = true; 
    372372    monitor.Notify(l); 
    373     RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Notified"); 
    374   } 
    375   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Leaving"); 
     373    RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Notified"); 
     374  } 
     375  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Leaving"); 
    376376} 
    377377 
     
    389389  { 
    390390    //printf("Failed making thread a real-time thread. Possibly current user has insufficient rights.\n"); 
    391     RRLIB_LOG_PRINT(eLL_ERROR, "Failed making thread a real-time thread. Possibly current user has insufficient rights."); 
     391    RRLIB_LOG_PRINT(ERROR, "Failed making thread a real-time thread. Possibly current user has insufficient rights."); 
    392392  } 
    393393} 
     
    434434void tThread::Start() 
    435435{ 
    436   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Entering"); 
    437   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "PreMutex"); 
     436  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Entering"); 
     437  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "PreMutex"); 
    438438  tLock l(*this); 
    439   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Locked"); 
     439  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Locked"); 
    440440  start_signal = true; 
    441441  monitor.Notify(l); 
    442   RRLIB_LOG_PRINT(eLL_DEBUG_VERBOSE_2, "Notified thread"); 
     442  RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Notified thread"); 
    443443} 
    444444 
     
    447447  if (unknown_thread) 
    448448  { 
    449     RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Operation not supported for threads of unknown origin."); 
     449    RRLIB_LOG_PRINT(WARNING, "Operation not supported for threads of unknown origin."); 
    450450    return; 
    451451  } 
     
    466466  stopping_threadz = true; 
    467467  const char*(*GetLogDescription)() = GetLogDescriptionStatic; 
    468   RRLIB_LOG_PRINT(eLL_USER, "Stopping all threads"); 
     468  RRLIB_LOG_PRINT(USER, "Stopping all threads"); 
    469469 
    470470  tLock lock(internal::GetThreadList()->obj_mutex); 
     
    514514      if (t->unknown_thread) 
    515515      { 
    516         RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "Do not know how to stop thread '", t->GetLogDescription(), "' of unknown origin."); 
     516        RRLIB_LOG_PRINT(WARNING, "Do not know how to stop thread '", t->GetLogDescription(), "' of unknown origin."); 
    517517        continue; 
    518518      } 
    519519 
    520       RRLIB_LOG_PRINT(eLL_DEBUG, "Stopping thread '", t->GetLogDescription(), "'"); 
     520      RRLIB_LOG_PRINT(DEBUG, "Stopping thread '", t->GetLogDescription(), "'"); 
    521521      tLock l(*t); 
    522522      t->stop_signal = true; 
  • tThread.h

    r4 r5  
    240240  virtual void Run() 
    241241  { 
    242     RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "No Run method implemented."); 
     242    RRLIB_LOG_PRINT(WARNING, "No Run method implemented."); 
    243243  } 
    244244 
Note: See TracChangeset for help on using the changeset viewer.