Changeset 852b1ce in tol
- Timestamp:
- May 2, 2013, 10:52:54 AM (13 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 4acc8bd
- Parents:
- 6fce577
- File:
-
- 1 edited
-
tol/btol/bgrammar/oprimp.cpp (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bgrammar/oprimp.cpp
r6fce577 r852b1ce 22 22 //#define TRACE_LEVEL 1 23 23 24 #define DONOT_USE_THREAD_PROFILE 25 24 26 #include <iostream> 25 #include <boost/asio.hpp> 27 28 #ifndef DONOT_USE_THREAD_PROFILE 26 29 #include <boost/date_time/posix_time/posix_time.hpp> 27 30 #include <boost/thread/thread.hpp> 28 31 #include <boost/thread/shared_mutex.hpp> 29 32 #include <boost/thread/locks.hpp> 33 #endif 30 34 31 35 #if defined(_MSC_VER) … … 79 83 #ifdef Do_TolOprProfiler 80 84 85 #ifndef DONOT_USE_THREAD_PROFILE 81 86 typedef boost::shared_mutex Lock; 82 87 typedef boost::unique_lock< Lock > WriteLock; … … 85 90 Lock myLock; 86 91 92 #define WRITE_LOCK \ 93 WriteLock w_lock(myLock); 94 #define READ_LOCK \ 95 ReadLock r_lock(myLock); 96 87 97 void SampleProfiler(); 98 #else 99 #define WRITE_LOCK 100 #define READ_LOCK 101 #endif 88 102 89 103 //-------------------------------------------------------------------- … … 111 125 static BTolOprProfiler* ptrCurrentProfiler; 112 126 static size_t TickResolution; 127 128 #ifndef DONOT_USE_THREAD_PROFILE 113 129 static boost::thread *ptrThread; 130 #endif 114 131 115 132 struct CalllingStr … … 283 300 static void StartThread() 284 301 { 302 #ifndef DONOT_USE_THREAD_PROFILE 285 303 if (!BTolOprProfiler::ptrThread) 286 304 { 287 305 BTolOprProfiler::ptrThread = new boost::thread(&SampleProfiler); 288 306 } 307 #endif 289 308 } 290 309 291 310 static void StopThread() 292 311 { 312 #ifndef DONOT_USE_THREAD_PROFILE 293 313 if (BTolOprProfiler::ptrThread) 294 314 { … … 297 317 BTolOprProfiler::ptrThread = NULL; 298 318 } 319 #endif 299 320 } 300 321 … … 302 323 { 303 324 // REVIEW: adquire an exclusive lock 304 W riteLock w_lock(myLock);325 WRITE_LOCK; 305 326 BTolOprProfiler::ptrCurrentProfiler = profiler; 306 327 // REVIEW: release the lock (released when leaving scope … … 310 331 { 311 332 // REVIEW: adquire an exclusive lock 312 R eadLock r_lock(myLock);333 READ_LOCK; 313 334 return BTolOprProfiler::ptrCurrentProfiler; 314 335 // REVIEW: release the lock (released when leaving scope … … 318 339 { 319 340 // REVIEW: adquire a lock 320 W riteLock w_lock(myLock);341 WRITE_LOCK; 321 342 if (BTolOprProfiler::ptrCurrentProfiler) 322 343 { … … 330 351 { 331 352 // REVIEW: adquire a lock 332 W riteLock w_lock(myLock);353 WRITE_LOCK; 333 354 if (BTolOprProfiler::ptrCurrentProfiler) 334 355 { … … 344 365 { 345 366 // REVIEW: adquire a lock 346 R eadLock r_lock(myLock);367 READ_LOCK; 347 368 if (BTolOprProfiler::ptrCurrentProfiler) 348 369 { … … 356 377 { 357 378 // REVIEW: adquire a lock 358 W riteLock w_lock(myLock);379 WRITE_LOCK; 359 380 size_t previous = BTolOprProfiler::TickResolution; 360 381 BTolOprProfiler::TickResolution = resolution; … … 366 387 { 367 388 // REVIEW: adquire a lock 368 R eadLock r_lock(myLock);389 READ_LOCK; 369 390 return BTolOprProfiler::TickResolution; 370 391 // REVIEW: release the lock, released when leaving scope … … 558 579 void SampleProfiler() 559 580 { 581 #ifndef DONOT_USE_THREAD_PROFILE 560 582 size_t resolution = BTolOprProfiler::GetTickResolution(); 561 583 while(1) … … 565 587 boost::this_thread::sleep(boost::posix_time::microseconds(resolution)); 566 588 } 589 #endif 567 590 } 568 591 … … 603 626 //-------------------------------------------------------------------- 604 627 { 628 #ifndef DONOT_USE_THREAD_PROFILE 605 629 if (BTolOprProfiler::ptrThread) 606 630 { … … 609 633 return; 610 634 } 635 #endif 611 636 double freq = Real(Arg(1)); 612 637 BTolOprProfiler::enabled_ = 1; … … 641 666 BTolOprProfiler* BTolOprProfiler::ptrCurrentProfiler = NULL; 642 667 size_t BTolOprProfiler::TickResolution = 1; 668 669 #ifndef DONOT_USE_THREAD_PROFILE 643 670 boost::thread *BTolOprProfiler::ptrThread = NULL; 671 #endif 644 672 645 673 int BTolOprProfiler_Init() { return(BTolOprProfiler::Initialize()); }
Note: See TracChangeset
for help on using the changeset viewer.
