~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to src/ts_log/thread_safe_log.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2010-09-27 10:06:11 UTC
  • mfrom: (1.2.11 upstream) (3.3.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100927100611-mx7828o8qomjdqgd
Tags: 2.1.3-1
* New Upstream version 2.1.3
* Bumped Standards-Version to 3.9.1, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
                                        for ( int idx = 0; idx < m_pThis->m_nSumOfPriorities; ++idx)
95
95
                                        {
96
96
                                                LogWrites & writes = *( m_pThis->m_aWritesTo[ m_pThis->m_idxWrite]);
97
 
                                                if ( writes.m_astr.size() > 0)
 
97
                                                if (!writes.m_astr.empty())
98
98
                                                        // we found a log that we should write to
99
99
                                                        break;
100
100
                                                ++m_pThis->m_idxWrite;
102
102
                                        }
103
103
                                        // did we find a log with messages that should be written to it?
104
104
                                        LogWrites & writes = *( m_pThis->m_aWritesTo[ m_pThis->m_idxWrite]);
105
 
                                        if ( writes.m_astr.size() > 0)
 
105
                                        if ( !writes.m_astr.empty())
106
106
                                        {
107
107
                                                // we get the string(s) to write to this log
108
108
                                                pLog = writes.m_pDestLog;
119
119
                                                }
120
120
                                                // we flush only when there are no more messages to write
121
121
                                                // (flushing could be time-consuming)
122
 
                                                bDoFlush = ( writes.m_astr.size() == 0);
 
122
                                                bDoFlush = writes.m_astr.empty();
123
123
                                        }
124
124
                                        // ... only when there are no more messages,
125
125
                                        //    will we ask if we should be destructed
131
131
                                        }
132
132
                                } // end locked block
133
133
                                // write the string(s)
134
 
                                if ( astrMsgs.size() > 0)
 
134
                                if ( !astrMsgs.empty())
135
135
                                {
136
136
                                        std::vector< std::string *>::iterator
137
137
                                                first = astrMsgs.begin(), last = astrMsgs.end();
147
147
                                }
148
148
                                else
149
149
                                        // nothing to write - wait
150
 
                                        thread_manager::sleep( 1);
 
150
                                        thread_manager::sleep( 100);
151
151
                                continue;
152
152
                        unlock_and_sleep:
153
 
                                thread_manager::sleep( 1);
 
153
                                thread_manager::sleep( 100);
154
154
                                continue;
155
155
                        } // while(true)
156
156
                } // virtual operator()()
350
350
                                {
351
351
                                        auto_lock_unlock locker( m_pThis->m_cs);
352
352
                                        // get the string
353
 
                                        if ( m_pThis->m_astrMessages.size() > 0)
 
353
                                        if ( !m_pThis->m_astrMessages.empty())
354
354
                                        {
355
355
                                                pstr = m_pThis->m_astrMessages.front();
356
356
                                                m_pThis->m_astrMessages.pop();
357
357
                                                // we flush only when there are no more messages to write
358
358
                                                // (flushing could be time-consuming)
359
 
                                                bDoFlush = ( m_pThis->m_astrMessages.size() == 0);
 
359
                                                bDoFlush = m_pThis->m_astrMessages.empty();
360
360
                                        }
361
361
                                        // ... only when there are no more messages,
362
362
                                        //    will we ask if we should be destructed
363
363
                                        else if ( m_pThis->m_bShouldBeDestructed)
364
364
                                        {
365
365
                                                // signal to the other thread we've finished
 
366
                                                m_pThis->m_underlyingLog << "Log writter thread finished." << std::endl;
 
367
                                                m_pThis->m_underlyingLog.flush();
366
368
                                                m_bHasFinished = true;
367
369
                                                return;
368
370
                                        }
377
379
                                }
378
380
                                else
379
381
                                        // nothing to write - wait
380
 
                                        thread_manager::sleep( 1);
 
382
                                        thread_manager::sleep( 100);
381
383
                        }
382
384
                }
383
385
                this_class * m_pThis;