(milliseconds, proc, clientData)
| 923 | * Results: |
| 924 | * The return value is a token for the timer event, which |
| 925 | * may be used to delete the event before it fires. |
| 926 | * |
| 927 | * Side effects: |
| 928 | * When milliseconds have elapsed, proc will be invoked |
| 929 | * exactly once. |
| 930 | * |
| 931 | *-------------------------------------------------------------- |
| 932 | */ |
| 933 | |
| 934 | Tk_TimerToken |
| 935 | Tk_CreateTimerHandler(milliseconds, proc, clientData) |
| 936 | int milliseconds; /* How many milliseconds to wait |
| 937 | * before invoking proc. */ |
| 938 | Tk_TimerProc *proc; /* Procedure to invoke. */ |
| 939 | ClientData clientData; /* Arbitrary data to pass to proc. */ |
| 940 | { |
| 941 | register TimerEvent *timerPtr, *tPtr2, *prevPtr; |
| 942 | static int id = 0; |
| 943 | |
| 944 | timerPtr = NewTimerEvent(); |
| 945 | |
| 946 | /* |
| 947 | * Compute when the event should fire. |
| 948 | */ |
| 949 | |
| 950 | (void) gettimeofday(&timerPtr->time, (struct timezone *) NULL); |
| 951 | timerPtr->time.tv_sec += milliseconds/1000; |
| 952 | timerPtr->time.tv_usec += (milliseconds%1000)*1000; |
| 953 | if (timerPtr->time.tv_usec > 1000000) { |
| 954 | timerPtr->time.tv_usec -= 1000000; |
| 955 | timerPtr->time.tv_sec += 1; |
| 956 | } |
| 957 | |
| 958 | /* |
| 959 | * Fill in other fields for the event. |
| 960 | */ |
| 961 | |
| 962 | timerPtr->proc = proc; |
| 963 | timerPtr->clientData = clientData; |
| 964 | id++; |
| 965 | timerPtr->token = (Tk_TimerToken) id; |
| 966 | |
| 967 | /* |
| 968 | * Add the event to the queue in the correct position |
| 969 | * (ordered by event firing time). |
| 970 | */ |
| 971 | |
| 972 | for (tPtr2 = timerQueue, prevPtr = NULL; tPtr2 != NULL; |
| 973 | prevPtr = tPtr2, tPtr2 = tPtr2->nextPtr) { |
| 974 | if ((tPtr2->time.tv_sec > timerPtr->time.tv_sec) |
| 975 | || ((tPtr2->time.tv_sec == timerPtr->time.tv_sec) |
| 976 | && (tPtr2->time.tv_usec > timerPtr->time.tv_usec))) { |
| 977 | break; |
| 978 | } |
| 979 | } |
| 980 | if (prevPtr == NULL) { |
| 981 | timerPtr->nextPtr = timerQueue; |
| 982 | timerQueue = timerPtr; |
no outgoing calls
no test coverage detected