1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #include "tools/AsynchronousCall.hxx" 28 29 #include <boost/bind.hpp> 30 #include "DrawViewShell.hxx" 31 32 namespace sd { namespace tools { 33 34 AsynchronousCall::AsynchronousCall (void) 35 : maTimer(), 36 mpFunction() 37 { 38 Link aCallback (LINK(this,AsynchronousCall,TimerCallback)); 39 maTimer.SetTimeoutHdl(aCallback); 40 } 41 42 43 44 45 AsynchronousCall::~AsynchronousCall (void) 46 { 47 mpFunction.reset(); 48 maTimer.Stop(); 49 } 50 51 52 53 54 void AsynchronousCall::Post ( 55 const AsynchronousFunction& rFunction, 56 sal_uInt32 nTimeoutInMilliseconds) 57 { 58 mpFunction.reset(new AsynchronousFunction(rFunction)); 59 maTimer.SetTimeout(nTimeoutInMilliseconds); 60 maTimer.Start(); 61 } 62 63 64 65 66 IMPL_LINK(AsynchronousCall,TimerCallback,Timer*,pTimer) 67 { 68 if (pTimer == &maTimer) 69 { 70 ::std::auto_ptr<AsynchronousFunction> pFunction (mpFunction); 71 mpFunction.reset(); 72 (*pFunction)(); 73 } 74 return 0; 75 } 76 77 78 } } // end of namespace ::sd::tools 79