Boost logo

Boost Users :

Subject: Re: [Boost-users] Why does `boost::asio::deadline_timer` allocate a `timer_queue` instance for each `deadline_timer` object?
From: Wang Danqi (beyondwdq_at_[hidden])
Date: 2014-11-15 20:57:44


I read the code again and find my mistake. The actual relationship is
as follows:

* `basic_deadline_timer` is the i/o object type, one instance for each
deadline_timer;
* `deadline_timer_service` is the service type, one per `io_service`,
retrieved by the constructor of `basic_io_object`;
* `detail::deadline_timer_service` is the service implementation type,
one per service, hen one per `io_serive` as well. It is defined as the
data member of `deadline_timer_service`;
* `detail::deadline_timer_service::implementation_type`: the
implementation type of the timer, one per `deadline_timer`.

As `timer_queue_` is a member of `detail::deadline_timer_service`, it
is one per `io_service` as well. Looks reasonable for me now.

The highscore link seems have merged the service implementation type
and timer implementation type into one, which is a bit misleading.

Thanks.
Danqi

On Sun, Nov 16, 2014 at 12:58 AM, Bjorn Reese <breese_at_[hidden]> wrote:
> On 11/15/2014 04:24 PM, Wang Danqi wrote:
>
>> There will be a single instance of `deadline_timer_service` serving
>> many `deadline_timer` objects. An instance of
>> `detail::deadline_timer_service` is created for each `deadline_timer`
>> object.
>
>
> All the deadline_timer objects obtain a pointer to the same
> detail::deadline_time_service (via the basic_io_object constructor)
> so there is at most one instance per io_service.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
Best wishes,
Wang Danqi

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net