LibreOffice Module sd (master) 1
TimerBasedTaskExecution.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <vcl/timer.hxx>
23
24#include <memory>
25
26namespace sd::tools {
27
28class AsynchronousTask;
29
39{
40public:
50 static std::shared_ptr<TimerBasedTaskExecution> Create (
51 const std::shared_ptr<AsynchronousTask>& rpTask,
52 sal_uInt32 nMillisecondsBetweenSteps,
53 sal_uInt32 nMaxTimePerStep);
54
58 void Release();
59
64 static void ReleaseTask (const std::weak_ptr<TimerBasedTaskExecution>& rpTask);
65
66private:
67 std::shared_ptr<AsynchronousTask> mpTask;
72 std::shared_ptr<TimerBasedTaskExecution> mpSelf;
73 sal_uInt32 mnMaxTimePerStep;
74
76 std::shared_ptr<AsynchronousTask> pTask,
77 sal_uInt32 nMillisecondsBetweenSteps,
78 sal_uInt32 nMaxTimePerStep);
80
81 class Deleter;
82 friend class Deleter;
83
84 DECL_LINK(TimerCallback, Timer *, void);
85};
86
87} // end of namespace ::sd::tools
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Used by the shared_ptr instead of the private destructor.
Execute an AsynchronousTask timer based, i.e.
DECL_LINK(TimerCallback, Timer *, void)
static void ReleaseTask(const std::weak_ptr< TimerBasedTaskExecution > &rpTask)
Convenience method that calls Release() on the given task.
static std::shared_ptr< TimerBasedTaskExecution > Create(const std::shared_ptr< AsynchronousTask > &rpTask, sal_uInt32 nMillisecondsBetweenSteps, sal_uInt32 nMaxTimePerStep)
Create a new object of this class.
void Release()
Stop the execution of the task and release the shared pointer to itself so that it will eventually be...
std::shared_ptr< AsynchronousTask > mpTask
std::shared_ptr< TimerBasedTaskExecution > mpSelf
This shared_ptr to this is used to destroy a TimerBasedTaskExecution object when its task has been ex...
TimerBasedTaskExecution(std::shared_ptr< AsynchronousTask > pTask, sal_uInt32 nMillisecondsBetweenSteps, sal_uInt32 nMaxTimePerStep)