#include <timeutil.h>
Public Member Functions | |
CMuxAlarm (void) | |
void | Sleep (CLinearTimeDelta ltd) |
void | SurrenderSlice (void) |
void | Set (CLinearTimeDelta ltdDeadline) |
void | Clear (void) |
void | Signal (void) |
Data Fields | |
bool | bAlarmed |
Private Attributes | |
bool | bAlarmSet |
Definition at line 124 of file timeutil.h.
CMuxAlarm::CMuxAlarm | ( | void | ) |
void CMuxAlarm::Clear | ( | void | ) |
Definition at line 1804 of file timeutil.cpp.
References bAlarmed, and bAlarmSet.
Referenced by boot_slave(), do_command(), fork_and_dump(), and Task_RunQueueEntry().
01805 { 01806 #ifdef HAVE_SETITIMER 01807 // Turn off the timer. 01808 // 01809 struct itimerval it; 01810 it.it_value.tv_sec = 0; 01811 it.it_value.tv_usec = 0; 01812 it.it_interval.tv_sec = 0; 01813 it.it_interval.tv_usec = 0; 01814 setitimer(ITIMER_PROF, &it, NULL); 01815 bAlarmSet = false; 01816 bAlarmed = false; 01817 #endif 01818 }
void CMuxAlarm::Set | ( | CLinearTimeDelta | ltdDeadline | ) |
Definition at line 1791 of file timeutil.cpp.
References bAlarmed, bAlarmSet, and CLinearTimeDelta::ReturnTimeValueStruct().
Referenced by do_command(), and Task_RunQueueEntry().
01792 { 01793 #ifdef HAVE_SETITIMER 01794 struct itimerval it; 01795 ltd.ReturnTimeValueStruct(&it.it_value); 01796 it.it_interval.tv_sec = 0; 01797 it.it_interval.tv_usec = 0; 01798 setitimer(ITIMER_PROF, &it, NULL); 01799 bAlarmSet = true; 01800 bAlarmed = false; 01801 #endif 01802 }
void CMuxAlarm::Signal | ( | void | ) |
Definition at line 1820 of file timeutil.cpp.
References bAlarmed, and bAlarmSet.
Referenced by sighandler().
void CMuxAlarm::Sleep | ( | CLinearTimeDelta | ltd | ) |
Definition at line 1715 of file timeutil.cpp.
References bAlarmSet, mudstate, CLinearTimeDelta::ReturnMicroseconds(), CLinearTimeDelta::ReturnSeconds(), and statedata::shutdown_flag.
Referenced by dump_database(), CHashFile::Insert(), CHashPage::ReadPage(), and CHashPage::WritePage().
01716 { 01717 #if defined(HAVE_NANOSLEEP) 01718 struct timespec req; 01719 ltd.ReturnTimeSpecStruct(&req); 01720 while (!mudstate.shutdown_flag) 01721 { 01722 struct timespec rem; 01723 if ( nanosleep(&req, &rem) == -1 01724 && errno == EINTR) 01725 { 01726 req = rem; 01727 } 01728 else 01729 { 01730 break; 01731 } 01732 } 01733 #else 01734 #ifdef HAVE_SETITIMER 01735 struct itimerval oit; 01736 bool bSaved = false; 01737 if (bAlarmSet) 01738 { 01739 // Save existing timer and disable. 01740 // 01741 struct itimerval it; 01742 it.it_value.tv_sec = 0; 01743 it.it_value.tv_usec = 0; 01744 it.it_interval.tv_sec = 0; 01745 it.it_interval.tv_usec = 0; 01746 setitimer(ITIMER_PROF, &it, &oit); 01747 bSaved = true; 01748 bAlarmSet = false; 01749 } 01750 #endif 01751 #if defined(HAVE_USLEEP) 01752 #define TIME_1S 1000000 01753 unsigned long usec; 01754 INT64 usecTotal = ltd.ReturnMicroseconds(); 01755 01756 while ( usecTotal 01757 && mudstate.shutdown_flag) 01758 { 01759 usec = usecTotal; 01760 if (usecTotal < TIME_1S) 01761 { 01762 usec = usecTotal; 01763 } 01764 else 01765 { 01766 usec = TIME_1S-1; 01767 } 01768 usleep(usec); 01769 usecTotal -= usec; 01770 } 01771 #else 01772 ::sleep(ltd.ReturnSeconds()); 01773 #endif 01774 #ifdef HAVE_SETITIMER 01775 if (bSaved) 01776 { 01777 // Restore and re-enabled timer. 01778 // 01779 setitimer(ITIMER_PROF, &oit, NULL); 01780 bAlarmSet = true; 01781 } 01782 #endif 01783 #endif 01784 }
void CMuxAlarm::SurrenderSlice | ( | void | ) |
bool CMuxAlarm::bAlarmed |
Definition at line 133 of file timeutil.h.
Referenced by check_filter(), Clear(), CMuxAlarm(), compile_regex(), did_it(), do_command(), do_mail_review(), eval_boolexp(), filter_handler(), FUNCTION(), grep_util(), list_check(), match(), modSpeech(), mux_exec(), page_return(), real_regmatch(), real_regrab(), regexp_match(), Set(), Signal(), switch_handler(), Task_RunQueueEntry(), and u_comp().
bool CMuxAlarm::bAlarmSet [private] |
Definition at line 127 of file timeutil.h.
Referenced by Clear(), CMuxAlarm(), Set(), Signal(), and Sleep().