Skip to content

boost::asio::deadline_timer spawns a thread for each timer on Windows #15

@johnwason

Description

@johnwason

My application uses lots of deadline_timers to provide timeout functionality for asynchronous operations. It appears that each deadline_timer spawns a thread to manage the wait on Windows. The threads don't complete once I call cancel on the timer. This leads to rapid resource exhaustion. On Windows the best way to implement the timers would be using "CreateTimerQueueTimer". The callback for the timer could then simply post the completion routines to the io_service. Using the flag WT_EXECUTEINTIMERTHREAD could potentially eliminate and performance penalties with the callback although I am not certain if it is legal given the design of asio on Windows. There is some discussion about the accuracy of this function but on windows it is nearly impossible to get timing resolution below ~15 ms using any method so I don't think that should be an issue. I am developing a work-around for my application and can send you the result if you are interested.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682485%28v=vs.85%29.aspx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions