Actions
Feature #2442
closedRe-license and move ScopedEventId (generalized) implementation from NFD codebase
Start date:
Due date:
% Done:
100%
Estimated time:
Description
ScopedEventId can be useful in many other places besides NFD. The only difference that ScopedEventId in the library should not be tied to global scheduler instance.
As a result, there is interface change and one interface limitation (no longer possible to implicitly convert EventId to ScopedEventId).
Here is a modified version of API:
/** \brief Event that is automatically cancelled upon destruction
*/
class ScopedEventId : noncopyable
{
public:
/** \brief Construct ScopedEventId tied to the specified scheduler
* \param scheduler Scheduler to which the event is tied
*/
ScopedEventId(Scheduler& scheduler);
/** \brief move constructor
*/
ScopedEventId(ScopedEventId&& other);
/** \brief assigns an event
*
* If a different event has been assigned to this instance previously,
* that event will be cancelled immediately.
*
* \note The caller should ensure that ScopedEventId is tied to a correct scheduler.
* Behavior is undefined when assigning event scheduled in another scheduler instance.
*/
ScopedEventId&
operator=(const EventId& event);
/** \brief cancels the event
*/
~ScopedEventId();
/** \brief cancels the event manually
*/
void
cancel();
/** \brief releases the event so that it won't be disconnected
* when this ScopedEventId is destructed
*/
void
release();
private:
Scheduler* m_scheduler; // pointer to allow move semantics
EventId m_event;
};
Actions