1 // The MIT License (MIT) 2 // 3 // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 // 5 // Permission is hereby granted, free of charge, to any person obtaining a copy 6 // of this software and associated documentation files (the "Software"), to deal 7 // in the Software without restriction, including without limitation the rights 8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 // copies of the Software, and to permit persons to whom the Software is 10 // furnished to do so, subject to the following conditions: 11 // 12 // The above copyright notice and this permission notice shall be included in 13 // all copies or substantial portions of the Software. 14 // 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 // THE SOFTWARE. 22 23 #pragma once 24 25 26 #ifdef MT_INSTRUMENTED_BUILD 27 28 29 namespace MT 30 { 31 32 class IProfilerEventListener 33 { 34 35 public: 36 IProfilerEventListener()37 IProfilerEventListener() {}; ~IProfilerEventListener()38 virtual ~IProfilerEventListener() {}; 39 40 // Called from main scheduler thread when all fibers has created (notify about fibers count) 41 virtual void OnFibersCreated(uint32 fibersCount) = 0; 42 43 // Called from main scheduler thread when all threads has created (notify about threads count) 44 virtual void OnThreadsCreated(uint32 threadsCount) = 0; 45 46 // Called from worker thread context when worker thread created 47 virtual void OnThreadCreated(uint32 workerIndex) = 0; 48 49 // Called from worker thread context when worker thread started 50 virtual void OnThreadStarted(uint32 workerIndex) = 0; 51 52 // Called from worker thread context when worker thread stopped 53 virtual void OnThreadStoped(uint32 workerIndex) = 0; 54 55 // Called from worker thread context when worker thread start to idle 56 virtual void OnThreadIdleStarted(uint32 workerIndex) = 0; 57 58 // Called from worker thread context when worker thread return to work from idle 59 virtual void OnThreadIdleFinished(uint32 workerIndex) = 0; 60 61 // Called from thread when thread is waiting for group 62 virtual void OnThreadWaitStarted() = 0; 63 64 // Called from thread when thread is finished waiting for group 65 virtual void OnThreadWaitFinished() = 0; 66 67 // Called from thread when waiting thread temporary convert to worker 68 virtual void OnTemporaryWorkerThreadJoin() = 0; 69 70 // Called from thread when temporary worker leave 71 virtual void OnTemporaryWorkerThreadLeave() = 0; 72 73 // Called from the worker thread that has change the task execution state 74 virtual void OnTaskExecuteStateChanged(MT::Color::Type debugColor, const mt_char* debugID, TaskExecuteState::Type type, int32 fiberIndex) = 0; 75 }; 76 77 } 78 79 80 #endif 81