FreeRDP
synch/timer.c File Reference
#include <winpr/config.h>
#include <winpr/crt.h>
#include <winpr/file.h>
#include <winpr/assert.h>
#include <winpr/sysinfo.h>
#include <winpr/synch.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <signal.h>
#include "event.h"
#include "synch.h"
#include "../handle/handle.h"
#include "../thread/thread.h"
#include "../log.h"

Macros

#define TAG   WINPR_TAG("synch.timer")
 

Functions

static BOOL TimerCloseHandle (HANDLE handle)
 
static BOOL TimerIsHandled (HANDLE handle)
 
static int TimerGetFd (HANDLE handle)
 
static DWORD TimerCleanupHandle (HANDLE handle)
 
static void TimerPostDelete_APC (LPVOID arg)
 
static int InitializeWaitableTimer (WINPR_TIMER *timer)
 
static BOOL timer_drain_fd (int fd)
 
HANDLE CreateWaitableTimerA (LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset, LPCSTR lpTimerName)
 
HANDLE CreateWaitableTimerW (LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset, LPCWSTR lpTimerName)
 
HANDLE CreateWaitableTimerExA (LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess)
 
HANDLE CreateWaitableTimerExW (LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess)
 
static void timerAPC (LPVOID arg)
 
BOOL SetWaitableTimer (HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, BOOL fResume)
 
BOOL SetWaitableTimerEx (HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay)
 
HANDLE OpenWaitableTimerA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpTimerName)
 
HANDLE OpenWaitableTimerW (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpTimerName)
 
BOOL CancelWaitableTimer (HANDLE hTimer)
 
int GetTimerFileDescriptor (HANDLE hTimer)
 
static void timespec_add_ms (struct timespec *tspec, UINT32 ms)
 
static void timespec_gettimeofday (struct timespec *tspec)
 
static INT64 timespec_compare (const struct timespec *tspec1, const struct timespec *tspec2)
 
static void timespec_copy (struct timespec *dst, struct timespec *src)
 
static void InsertTimerQueueTimer (WINPR_TIMER_QUEUE_TIMER **pHead, WINPR_TIMER_QUEUE_TIMER *timer)
 
static void RemoveTimerQueueTimer (WINPR_TIMER_QUEUE_TIMER **pHead, WINPR_TIMER_QUEUE_TIMER *timer)
 
static int FireExpiredTimerQueueTimers (WINPR_TIMER_QUEUE *timerQueue)
 
static void * TimerQueueThread (void *arg)
 
static int StartTimerQueueThread (WINPR_TIMER_QUEUE *timerQueue)
 
HANDLE CreateTimerQueue (void)
 
BOOL DeleteTimerQueueEx (HANDLE TimerQueue, HANDLE CompletionEvent)
 
BOOL DeleteTimerQueue (HANDLE TimerQueue)
 
BOOL CreateTimerQueueTimer (PHANDLE phNewTimer, HANDLE TimerQueue, WAITORTIMERCALLBACK Callback, PVOID Parameter, DWORD DueTime, DWORD Period, ULONG Flags)
 
BOOL ChangeTimerQueueTimer (HANDLE TimerQueue, HANDLE Timer, ULONG DueTime, ULONG Period)
 
BOOL DeleteTimerQueueTimer (HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEvent)
 

Variables

static HANDLE_OPS ops
 

Macro Definition Documentation

◆ TAG

#define TAG   WINPR_TAG("synch.timer")

WinPR: Windows Portable Runtime Synchronization Functions

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2021 David Fort conta.nosp@m.ct@h.nosp@m.arden.nosp@m.ing-.nosp@m.consu.nosp@m.ltin.nosp@m.g.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ CancelWaitableTimer()

BOOL CancelWaitableTimer ( HANDLE  hTimer)
Here is the call graph for this function:

◆ ChangeTimerQueueTimer()

BOOL ChangeTimerQueueTimer ( HANDLE  TimerQueue,
HANDLE  Timer,
ULONG  DueTime,
ULONG  Period 
)
Here is the call graph for this function:

◆ CreateTimerQueue()

HANDLE CreateTimerQueue ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateTimerQueueTimer()

BOOL CreateTimerQueueTimer ( PHANDLE  phNewTimer,
HANDLE  TimerQueue,
WAITORTIMERCALLBACK  Callback,
PVOID  Parameter,
DWORD  DueTime,
DWORD  Period,
ULONG  Flags 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateWaitableTimerA()

HANDLE CreateWaitableTimerA ( LPSECURITY_ATTRIBUTES  lpTimerAttributes,
BOOL  bManualReset,
LPCSTR  lpTimerName 
)

Waitable Timer

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateWaitableTimerExA()

HANDLE CreateWaitableTimerExA ( LPSECURITY_ATTRIBUTES  lpTimerAttributes,
LPCSTR  lpTimerName,
DWORD  dwFlags,
DWORD  dwDesiredAccess 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateWaitableTimerExW()

HANDLE CreateWaitableTimerExW ( LPSECURITY_ATTRIBUTES  lpTimerAttributes,
LPCWSTR  lpTimerName,
DWORD  dwFlags,
DWORD  dwDesiredAccess 
)
Here is the call graph for this function:

◆ CreateWaitableTimerW()

HANDLE CreateWaitableTimerW ( LPSECURITY_ATTRIBUTES  lpTimerAttributes,
BOOL  bManualReset,
LPCWSTR  lpTimerName 
)
Here is the call graph for this function:

◆ DeleteTimerQueue()

BOOL DeleteTimerQueue ( HANDLE  TimerQueue)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteTimerQueueEx()

BOOL DeleteTimerQueueEx ( HANDLE  TimerQueue,
HANDLE  CompletionEvent 
)

Quote from MSDN regarding CompletionEvent: If this parameter is INVALID_HANDLE_VALUE, the function waits for all callback functions to complete before returning. If this parameter is NULL, the function marks the timer for deletion and returns immediately.

Note: The current WinPR implementation implicitly waits for any callback functions to complete (see pthread_join above)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteTimerQueueTimer()

BOOL DeleteTimerQueueTimer ( HANDLE  TimerQueue,
HANDLE  Timer,
HANDLE  CompletionEvent 
)

Quote from MSDN regarding CompletionEvent: If this parameter is INVALID_HANDLE_VALUE, the function waits for all callback functions to complete before returning. If this parameter is NULL, the function marks the timer for deletion and returns immediately.

Note: The current WinPR implementation implicitly waits for any callback functions to complete (see cond_mutex usage)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FireExpiredTimerQueueTimers()

static int FireExpiredTimerQueueTimers ( WINPR_TIMER_QUEUE *  timerQueue)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTimerFileDescriptor()

int GetTimerFileDescriptor ( HANDLE  hTimer)
Here is the call graph for this function:

◆ InitializeWaitableTimer()

static int InitializeWaitableTimer ( WINPR_TIMER *  timer)
static
Here is the caller graph for this function:

◆ InsertTimerQueueTimer()

static void InsertTimerQueueTimer ( WINPR_TIMER_QUEUE_TIMER **  pHead,
WINPR_TIMER_QUEUE_TIMER *  timer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OpenWaitableTimerA()

HANDLE OpenWaitableTimerA ( DWORD  dwDesiredAccess,
BOOL  bInheritHandle,
LPCSTR  lpTimerName 
)

◆ OpenWaitableTimerW()

HANDLE OpenWaitableTimerW ( DWORD  dwDesiredAccess,
BOOL  bInheritHandle,
LPCWSTR  lpTimerName 
)

◆ RemoveTimerQueueTimer()

static void RemoveTimerQueueTimer ( WINPR_TIMER_QUEUE_TIMER **  pHead,
WINPR_TIMER_QUEUE_TIMER *  timer 
)
static
Here is the caller graph for this function:

◆ SetWaitableTimer()

BOOL SetWaitableTimer ( HANDLE  hTimer,
const LARGE_INTEGER *  lpDueTime,
LONG  lPeriod,
PTIMERAPCROUTINE  pfnCompletionRoutine,
LPVOID  lpArgToCompletionRoutine,
BOOL  fResume 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetWaitableTimerEx()

BOOL SetWaitableTimerEx ( HANDLE  hTimer,
const LARGE_INTEGER *  lpDueTime,
LONG  lPeriod,
PTIMERAPCROUTINE  pfnCompletionRoutine,
LPVOID  lpArgToCompletionRoutine,
PREASON_CONTEXT  WakeContext,
ULONG  TolerableDelay 
)
Here is the call graph for this function:

◆ StartTimerQueueThread()

static int StartTimerQueueThread ( WINPR_TIMER_QUEUE *  timerQueue)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timer_drain_fd()

static BOOL timer_drain_fd ( int  fd)
static
Here is the caller graph for this function:

◆ timerAPC()

static void timerAPC ( LPVOID  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimerCleanupHandle()

static DWORD TimerCleanupHandle ( HANDLE  handle)
static
Here is the call graph for this function:

◆ TimerCloseHandle()

BOOL TimerCloseHandle ( HANDLE  handle)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimerGetFd()

static int TimerGetFd ( HANDLE  handle)
static
Here is the call graph for this function:

◆ TimerIsHandled()

static BOOL TimerIsHandled ( HANDLE  handle)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimerPostDelete_APC()

static void TimerPostDelete_APC ( LPVOID  arg)
static
Here is the caller graph for this function:

◆ TimerQueueThread()

static void* TimerQueueThread ( void *  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timespec_add_ms()

static void timespec_add_ms ( struct timespec *  tspec,
UINT32  ms 
)
static

Timer-Queue Timer Design, Performance, and Optimization of Timer Strategies for Real-time ORBs: http://www.cs.wustl.edu/~schmidt/Timer_Queue.html

Here is the caller graph for this function:

◆ timespec_compare()

static INT64 timespec_compare ( const struct timespec *  tspec1,
const struct timespec *  tspec2 
)
static
Here is the caller graph for this function:

◆ timespec_copy()

static void timespec_copy ( struct timespec *  dst,
struct timespec *  src 
)
static
Here is the caller graph for this function:

◆ timespec_gettimeofday()

static void timespec_gettimeofday ( struct timespec *  tspec)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ops

HANDLE_OPS ops
static
Initial value:
NULL }
if availableBytes return NULL
Definition: TPCircularBuffer.h:109
static int TimerGetFd(HANDLE handle)
Definition: synch/timer.c:55
static BOOL TimerCloseHandle(HANDLE handle)
Definition: synch/timer.c:134
static BOOL TimerIsHandled(HANDLE handle)
Definition: synch/timer.c:50
static DWORD TimerCleanupHandle(HANDLE handle)
Definition: synch/timer.c:65