15bf2b6ebSBrian Hill /* 25bf2b6ebSBrian Hill * Copyright 2017 Haiku Inc. All rights reserved. 35bf2b6ebSBrian Hill * Distributed under the terms of the MIT License. 45bf2b6ebSBrian Hill * 55bf2b6ebSBrian Hill * Authors: 65bf2b6ebSBrian Hill * Brian Hill 75bf2b6ebSBrian Hill */ 85bf2b6ebSBrian Hill #ifndef TASKTIMER_H 95bf2b6ebSBrian Hill #define TASKTIMER_H 105bf2b6ebSBrian Hill 115bf2b6ebSBrian Hill 125bf2b6ebSBrian Hill #include <Alert.h> 135bf2b6ebSBrian Hill #include <Invoker.h> 145bf2b6ebSBrian Hill #include <Looper.h> 155bf2b6ebSBrian Hill #include <Message.h> 165bf2b6ebSBrian Hill #include <MessageRunner.h> 175bf2b6ebSBrian Hill #include <Messenger.h> 185bf2b6ebSBrian Hill #include <String.h> 195bf2b6ebSBrian Hill 205bf2b6ebSBrian Hill #include "RepoRow.h" 215bf2b6ebSBrian Hill 225bf2b6ebSBrian Hill class TaskTimer; 235bf2b6ebSBrian Hill class TaskLooper; 245bf2b6ebSBrian Hill 255bf2b6ebSBrian Hill 265bf2b6ebSBrian Hill typedef struct { 275bf2b6ebSBrian Hill RepoRow* rowItem; 285bf2b6ebSBrian Hill int32 taskType; 295bf2b6ebSBrian Hill BString name, taskParam; 305bf2b6ebSBrian Hill thread_id threadId; 315bf2b6ebSBrian Hill TaskLooper* owner; 325bf2b6ebSBrian Hill BString resultName, resultErrorDetails; 335bf2b6ebSBrian Hill TaskTimer* fTimer; 345bf2b6ebSBrian Hill } Task; 355bf2b6ebSBrian Hill 365bf2b6ebSBrian Hill 375bf2b6ebSBrian Hill class TaskTimer : public BLooper { 385bf2b6ebSBrian Hill public: 395bf2b6ebSBrian Hill TaskTimer(const BMessenger& target, Task* owner); 405bf2b6ebSBrian Hill ~TaskTimer(); 415bf2b6ebSBrian Hill virtual bool QuitRequested(); 425bf2b6ebSBrian Hill virtual void MessageReceived(BMessage*); 435bf2b6ebSBrian Hill void Start(const char* name); 445bf2b6ebSBrian Hill void Stop(const char* name); 455bf2b6ebSBrian Hill 465bf2b6ebSBrian Hill private: 47*856ecc7bSBrian Hill int32 _NextAlertStackCount(); 48*856ecc7bSBrian Hill 495bf2b6ebSBrian Hill int32 fTimeoutMicroSeconds; 505bf2b6ebSBrian Hill bool fTimerIsRunning; 515bf2b6ebSBrian Hill BString fRepositoryName; 525bf2b6ebSBrian Hill BMessenger fReplyTarget; 535bf2b6ebSBrian Hill BMessenger fMessenger; 545bf2b6ebSBrian Hill BMessageRunner* fMessageRunner; 555bf2b6ebSBrian Hill BMessage fTimeoutMessage; 565bf2b6ebSBrian Hill BAlert* fTimeoutAlert; 575bf2b6ebSBrian Hill BInvoker fTimeoutAlertInvoker; 585bf2b6ebSBrian Hill Task* fOwner; 595bf2b6ebSBrian Hill }; 605bf2b6ebSBrian Hill 615bf2b6ebSBrian Hill 625bf2b6ebSBrian Hill #endif 63