INOS
cinostask.h
Go to the documentation of this file.
1//******************************************************************************
26//******************************************************************************
27#ifndef INC_INOSTASK_H
28#define INC_INOSTASK_H
29//------------------------------------------------------------------------------
30// defines
31//------------------------------------------------------------------------------
32//
33//------------------------------------------------------------------------------
34// includes
35//------------------------------------------------------------------------------
36//
37// system
38//
39// C++
40#if defined(INOS_DESKTOP)
41#include <thread>
42#include <condition_variable>
43#endif
44//
45// project
46//
47//------------------------------------------------------------------------------
48// class definition
49//------------------------------------------------------------------------------
50//
52{
53 // public members
54 public:
81 void* apHandler=0, void* apObject=0);
82
89 CINOSTask(std::function<void(void*)> aFunction, void* apParam = nullptr,
91
99 CINOSTask(const char* apName, std::function<void(void*)> aFunction,
101
104 virtual ~CINOSTask();
105
111
115 virtual uint32 Join();
116
120 virtual void Detach();
121
125 virtual void Exit();
126
130 virtual void Exit(uint32 auExitCode);
131
137
141 { return m_uExitCode; };
142
146 virtual bool CheckShutdown()
147 { return (m_uTskFlags & eTskFlgShutdownRequest); };
148
152 virtual void SetSuspendHook(void* apSuspendHook)
153 {
154 #if defined(INOS_DESKTOP)
156 #else
157 if (apSuspendHook)
158 m_pSuspendHook = (void*) ((uintnbr)apSuspendHook | 3);
159 else
160 m_pSuspendHook = nullptr;
161 #endif
162 };
163
166 virtual void ClrSuspendHook()
167 {
168 m_pSuspendHook = nullptr;
169 };
170
173 virtual void* GetSuspendHook()
174 {
175 return m_pSuspendHook;
176 };
177
180 enum ETskType {
181 eTskTypeBoot = 0,
182 eTskTypeResource = 1,
183 eTskTypeSystem = 2,
184 eTskTypeApplication = 3,
185 eTskTypeCommunication = 4,
186 eTskTypeRealtime = 5,
187 eTskTypeInterrupt = 6,
188 eTskTypeBackground = 7,
189 eTskTypeLua = 8,
190 eTskTypeTest = 9,
191 eTskTypeReserved0 = 10,
192 eTskTypeReserved1 = 11,
193 eTskTypeUser0 = 12,
194 eTskTypeUser1 = 13,
195 eTskTypeUser2 = 14,
196 eTskTypeUser3 = 15,
197 };
198
202 {
203 return ETskType(m_eTskType&0xf);
204 };
205
214
215 // protected members
216 protected:
217
221 virtual void Action();
222
223#if defined(INOS_TIMINIG_CHECKS_SUSPEND)
225 virtual void OnResume(uint32 auLastState, uint32 auElapsedUs, void* apSync);
226#endif
227
229
230 // private members
231 private :
232
233 // friend classes
234 friend class CINOSMutex;
235 friend class CINOSSync;
236 friend class CINOSMultiSync;
237 friend class CINOSExceptionContext;
238 friend class CINOSExceptionCleanup;
239 friend class CINOSRegisterLoadDevice;
240 friend class CINOSWatchPoint;
241 friend class CINCODataLogger;
242 friend class CINCODataLoggerReader;
243 friend class CINFOLink;
244 friend class CINOSTaskQueue;
245 friend class CINOSTaskEx;
246 friend class CINOSTaskExMsg;
247 friend class CINCOTaskExProcedure;
248 friend class CINOSMcLua;
249 friend class CINOSMcMessage;
250 friend class CINOSMcCoord;
251 friend class CINOSConcurrencyCheck;
253 friend class CINCOEvtLoggerGet;
254 friend class CINCOObject;
255 friend class CINCOProcedure;
256 friend class CINOSSioTftExpProc;
257 friend class CINOSTestpoint;
258 friend class CINCOVThreadImpl;
259 friend class CINCOVParseProcedure;
260 friend class CINOSConditionVariable;
262 // hardware
263 friend class CINOSHwTarget;
264 friend class CINOSHwDevice;
265 friend class CINOSHwEthernet;
266
267
268
269 friend class CINOSHwDbg_P50XX;
270 friend class CINOSHwDbg_P2020;
271 friend class CINOSHwDbg_ppc750;
272 friend class CINOSHwDbg_CortexA9;
273 friend class CINOSHwDbg_CortexA72;
274
275 friend class CINOSHwIrq_P50XX;
276 friend class CINOSHwIrq_p2020;
277 friend class CINOSHwIrq_ppc750;
278 friend class CINOSHwIrq_CortexA9;
279 friend class CINOSHwIrq_CortexA72;
280
281 friend class CINOSHwCpu_p50XX;
282 friend class CINOSHwCpu_p2020;
283 friend class CINOSHwCpu_ppc750;
284 friend class CINOSHwCpu_CortexA9;
285 friend class CINOSHwCpu_CortexA72;
286
287 friend class CINOSHwTrp_P50XX;
288 friend class CINOSHwTrp_P2020;
289 friend class CINOSHwTrp_ppc750;
290 friend class CINOSHwTrp_CortexA9;
291 friend class CINOSHwTrp_CortexA72;
292 // kernel
293 friend class CINOSKernel;
294 friend class CINOSKernel_ARM;
295 friend class CINOSKernel_P50XX;
296 friend class CINOSKernel_P2020;
297 friend class CINOSKernel_PPC750;
298 friend class CINOSKernel_CortexA9;
299 friend class CINOSKernel_CortexA72;
300
301 friend void Ready(CINOSTask* apTask, uint32 auFlags);
302 friend void* _SetupTask(CINOSTask*);
303 #if defined (INOS_DESKTOP)
304 #if defined (INOS_WINDOWS)
305 friend long _Sleep(long aTime);
306 #else
307 friend long Sleep(long aTime);
308 #endif
309 #endif
310 friend void _suspend(uint32 auState);
311 friend void _suspend(uint32 auState, uint32 auFlags);
312 friend void _resume(CINOSTask* apTask);
313 friend void _resume(CINOSTask* apTask, uint32 auFlags);
314 friend void _preemption();
315 friend void _schedule();
316 friend void _changepriority(uint32 auPriority);
317 friend void _relinquish();
318 // friend functions
321 friend bool _CINOSExceptionContext__Save();
322 friend void SlaveVariable(class CINCOFrame* aFrame);
323
324 // Tests
325 friend class CTaskExTestImpl;
326 friend class CINOSTaskExMsgTest;
327 friend class CINOSStackCorruptionTest;
328
329
330 // private members
331 #if defined(INOS_TESTING)
332 public:
333 #else
334 private:
335 #endif
336 // task stack (has ro be the first local data)
337 void* pStack; // pointer to top of stack
338 void* pStackBegin; // pointer to start of stack
339 void* pStackEnd; // pointer to end of stack
340
342 void* m_pSuspendHook = nullptr;
343
344 // linked list pointers
345 CINOSTask* pNext; // pointer to next task in list
346 CINOSTask* pPrevious; // pointer to previous task in list
347
348 uint16 mState; // task state
349 uint16 mTrapNumber; // trap number if task on trap
350 uint32 mCycleTicks; // number of cpu ticks of one task cycle
351 uint8 mPriority; // task priority
352 uint8 mSavedPriority; // saved task priority
353 uint16 mUsecTimeSlice; // task timeslice (in usec)
354 uint16 mPreemptionCnt; // preemption counter
355 uint32 mBclkTimeSlice; // task timeslice (in bus clocks)
356 uintnbr mDecSave; // decrementer save
357 uintnbr mSavedMSR; // temporarly saved mrs over singelstep
358 public:
359 enum {
360 eTskFlgFloatingpoint = 0x00000001,
361 eTskFlgIrqDisabled = 0x00000002,
362 eTskFlgTimeslice = 0x00000004,
363 eTskFlgTimingFailureHaltTask = 0x00000008,
364 eTskFlgDebugTimingDisableIrq = 0x00000010,
365 eTskFlgStartupDone = 0x00000020,
366 eTskFlgShutdownRequest = 0x00000040,
367 eTskFlgFunctionValid = 0x00000080,
368 eTskFlgShutdownPending = 0x00000100,
369 eTskFlgStackProtection = 0x00000200,
370 eTskFlgPriorityCheck = 0x00000400,
371 eTskFlgSuspendTimingCheck = 0x00000800,
372 eTskFlgSuspendHookRunning = 0x00001000,
373 eTskFlgIncoTouch = 0x00002000,
374 };
375 uint32 m_uTskFlags;
377 uint32 m_uTskId = 0;
379 uint32 m_uTskNxtId = 0;
381 uint32 m_uTskPrvId = 0;
383 uint32 m_uTskParentId = 0;
385 volatile uint32 m_uTskLastChildId = 0;
386
387 // sync handling
388 private:
389 CINOSMutex* pActualMutex; // pointer to actual mutex
390
391 // IMPORTANT: Do not use this member in new projects, as it will not be available
392 // anymore in the future. But some projects of key customers rely on
393 // an 'only' protected' member.
394 protected:
395 CINOSSync* pActualSync; // pointer to actual sync object
396
397 private:
398 tTaskId m_idNxtWaiting; // id of next task waiting for a sync object
399
400 // exception handling members
401 private:
402 uint32 mExceptionState; // exception state
403 class CINOSException* pExceptionPending; // pointer to pending exception
404 class CINOSExceptionContext* pExceptionContext; // pointer to task exception context
405
406 // task data
407 private:
408 char* pName; // task name
409 char* pNameSave = nullptr;// task name used at shutdown
410 uint32 mTaskIdentification;// task id pattern (0x05640172)
411 _reent* m_pReentrancy; // pointer to _reent structure (libc reentrancy)
412 uint32 mTimer_1ms; // 1ms timer (for Sleep)
413
414 // timing data (all data in ticks (4 bus cycles (603) / 1 cpu cycle (403))
415 uint64 m_uTbRestore; // timebase at restore
416 uint64 m_uTbTask; // task timebase
417 uint32 m_uTbEntry; // timebase at method entry
418 uint32 m_uTbOld; // task timebase at last suspend
419 uint32 m_uTbAct; // actual used cpu time
420 uint32 m_uTbMin; // min. used cpu time
421 uint32 m_uTbMax; // max. used cpu time
422 uint32 mResumeTime; // timebase at task resume
423 uint64 mResumeTimeNs; // timebase at task resume [ns]
424 uint32 mMinResponseTime; // min. response time (resume until active)
425 uint32 mMaxResponseTime; // max. response time (resume until active)
426 uint32 mActResponseTime; // actual response time (resume until active)
427 uint32 mSinglestepInstruction; // The instruction which we singlestep. we need to store it because it can't always be calculated in the interrupt handler, becuase after a 'branch instruction', the stepped over instruction can't be calculated anymore.
428 uint32 m_uActivity;
429
430 uint16 mError; // task error (used for callprocedure etc.)
431 uint16 mClassSize; // size of class (used for delete operator)
432 static uint32 m_uDebugUpdateId; // update id that changes whenever a "debug setting" changes, such as breakpoint/watchpoint added, removed, etc.
433 void* m_pHandler;
434 void* m_pObject;
447 uint64 m_uBusTickAtIrq;
448
449 // private member functions
450 private :
451 // prepare stack context
452 void PrepareStack(bool aInterruptsDisabled, void* apHandler, void* apObject);
453 // main loop (called at startup)
454 void MainLoop();
455
456 // public debug functions
457 public :
462 enum ETaskErrorFlags {
463 // note: the lower Byte is currently used to send inco errors,
464 // such as 'wrong param count' (defRpcNumberParam) to the caller,
465 // therfore do not use the lower Byte
466
467 eFlagCalledByINCO = 0x100,
469#if defined(INCO_RETRY_AWARE_GETVARIABLE)
470 eFlagINCODenyRetries = 0x400
471#endif
472 };
473 virtual void MsgReply(
474 CINOSTaskExMsg* apMsg, uint32 auReply, uint32 aAppError)
475 {}
476 uint32 GetError()
477 {return mError;}
478 # if defined(INCO_DEPRECATED_CALLPROCEDURE_ERRORS)
479 // Some projects of key customers return CallProcedure errors via this SetError method
480 public:
481 #else
482 // SetError is private to avoid code that accidentally sets the error of the task with
483 // an unsupported error.
484 private:
485 #endif
486 void SetError(uint32 aError)
487 { mError=(uint16)aError;}
488 public:
489 uint32 GetId()
490 {return mTaskIdentification;}
491 void SetId(uint32 aId)
493 uint32 GetTaskId()
494 { return m_uTskId; }
495 uint32 GetParentId()
496 { return m_uTskParentId; }
497 uint32 GetState () const
498 { return mState;}
499 void SetState(uint16 aState)
500 { mState=aState;}
501 uint32 GetPriority()
502 { return mPriority;}
506 void SetPriority(uint32 auPriority);
507
508 uint32 GetTrapNumber()
509 { return mTrapNumber;}
510 void SetTrapNumber(uint32 aNumber)
511 { mTrapNumber = (uint16)aNumber;}
512 uint32 GetCycleTicks()
513 { return mCycleTicks&0x00ffffff;}
514 uint32 SetCycleTicks(uint32 auCycleTicks)
515 { return mCycleTicks = auCycleTicks;}
516 uint8 GetOversampling()
517 { return (uint8) ((mCycleTicks>>24)&0xff);}
518 void SetOversampling(uint8 auOversampling)
519 { mCycleTicks = (mCycleTicks&0x00ffffff)|(auOversampling<<24);}
520 uint32 GetResumeTicks()
521 { return mResumeTime;}
522 uint64 GetResumeTimeNs()
523 { return mResumeTimeNs;}
526 uint32 GetTbEntry()
527 { return m_uActivity;}
530 uint64 GetTbTask() const
531 {
532 uint32 uMsr = INOSDisableInterrupts();
533 uint64 uValue = m_uTbTask;
535 return uValue;
536 }
540 uint64 GetTbTaskReal() const
541 {
542 uint64 uCurrentTicks = GetSystemTicks();
543 const CINOSTask* pTask = ActualTask();
544 uint32 uMsr = INOSDisableInterrupts();
545 uint64 uTskTicks = pTask->m_uTbTask;
546 uint64 uTskRestore = pTask->m_uTbRestore;
549 return uTskTicks;
550 }
553 uint64 GetTbRestore() const
554 {
555 uint32 uMsr = INOSDisableInterrupts();
556 uint64 uValue = m_uTbRestore;
558 return uValue;
559 }
560 uint16 GetClassSize()
561 { return mClassSize;}
563 {
565 return m_pReentrancy;
566 };
567 uint32 GetReentrancyTouched()
568 {
570 };
571
572 char* GetName() const
573 { return pName;}
574 CINCOObject* iGetRegister();
575
576 uint32 SingleStep();
577 uint32 RangeStep(uint32 auFrom, uint32 auTo);
578 uint32 Halt();
579 uint32 Run();
580
581 uint32 GetPC(uintnbr* aValue);
582 uint32 PutPC(uintnbr aValue);
583 uint32 GetLR(uintnbr* aValue);
584 uint32 GetSPR(uint32 aNumber, uint32* aValue);
585 uint32 PutSPR(uint32 aNumber, uint32 aValue);
586 uint32 GetSPRs(uint32* aResult);
587 uint32 GetSPRsGdb(uint32* aResult);
588
589 uint32 GetGPR(uint32 aNumber, uint32* aValue);
590 uint32 PutGPR(uint32 aNumber, uint32 aValue);
592 uint32 GetGPRs(uint32* aResult, bool abNative=false);
593
596 uint32 GetGdbRegsSize(uint32& auSize);
597
600 uint32 GetGdbRegs(void* apData);
601
607 uint32 PutGdbReg(const uint32 auRegister, const void* apData, uint32 auDataLength);
608
609 uint32 GetFPR(uint32 aNumber, double* aValue);
610 uint32 PutFPR(uint32 aNumber, double aValue);
611 uint32 GetFPRs(double* aResult);
612 #ifdef E500V2
613 uint32 GetEVHs(uint32* aResult);
614 uint32 GetSPE(uint32* aResult);
615 #endif
616
617 uint32 GetTaskData(uint32 aDataDef, uintnbr* aResult, uint32& aLength);
618 uint32 PutTaskData(uint32 aDataDef, uint32* aData, uint32 aLength);
619
621 bool EnableFloatingPoint();
622
625 uint16 EnableExceptions();
626
629 void RestoreExceptions(uint16 auLevel);
630
634
635 // checks the passed address against the stack of this task and returns true
636 // if the address belongs to the tasks stack or false otherwise.
638 // return stack size [bytes]
639 uint32 GetStackSize() const;
640
641 // returns size of the stack that has never been allocated yet [bytes]
642 // this is used to determine the maximum stack usage so far in percent,
643 // and if this is zero, most likely a stack overflow happened at some time
644 uint32 GetStackSizeFree() const;
645
646 #if !defined(INOS_DESKTOP)
647 // return stack still left [bytes]
648 uintnbr GetStackLeft() const
649 {
650 uintnbr uSp;
651 #if defined(INOS_CPU_CORTEXA9)
652 asm volatile ("mov %0,sp" : "=r" (uSp));
653 #elif defined(INOS_CPU_CORTEXA72)
654 asm volatile ("mov %0,sp" : "=r" (uSp));
655 #else
656 asm volatile ("mr %0,1" : "=r" (uSp));
657 #endif
658 return uSp - (uintnbr)pStackEnd;
659 }
660 #endif
661
666 static uint32 GetDebugUpdateId();
669 static void ChangeDebugUpdateId();
670
671#ifdef INOS_STACKPROTECTION
672 void ProtectStack();
673 void UnprotectStack();
674 void StackProtectionEnable() {
676 }
679 }
680 bool StackProtectionEnabled() const {
682 }
683#endif
684
685 // protected member functions
686 protected :
687 // sleep 'aTime' ms and return 0 if the requested time was slept or the
688 // number of remaining ms if the task was resumed by someone else before
689 // aTime ms
690 #ifndef INOS_DESKTOP
691 friend long Sleep(long aTime);
692 #endif
693
694 // exception handling member functions
695 public:
696 // throw exception to myself
697 void ThrowException(CINOSException* aException);
698 // throw exception to myself (running in a context of a different task)
699 void ThrowExceptionToTask(CINOSException* aException);
700 // accept exception
701 void AcceptException();
702 // ignore exception
703 void IgnoreException();
704 #ifdef INOS_EXCEPTION_MUTEX
706 #endif
709 inline void SetBusTicksAtIrq(uint64 auBusTicks) {
710 #ifdef INOS_ARCH_ARM
712 #else
713 // avoid double instructions, because FP instructions are usually
714 // not allowed in the context of calling this function (e.g.
715 // GINLink interrupt context), because on PPC, the FP-unit is
716 // disabled and on ARM, the IRQ tasks do not save the FP-registers.
717 // That's why we need to ensure that the compiler doesn't generate
718 // FP-instructions.
719 const uint32* pSrc = reinterpret_cast<const uint32*>(&auBusTicks);
720 uint32* pDst = reinterpret_cast<uint32*>(&m_uBusTickAtIrq);
721 pDst[0] = pSrc[0];
722 pDst[1] = pSrc[1];
723 #endif
724 }
727 inline uint64 GetBusTicksAtIrq() const {
728 return m_uBusTickAtIrq;
729 }
730
731 // allow dynamic object handling (new/delete)
732 void* operator new(size_t aSize);
733 void operator delete(void* aPtr);
734
735 // private member functions
736 protected :
737 // create task
738 void Create(char* apName = nullptr, uint32 auStackSize=defDefaultStackSize,
741 void* apHandler=0, void* apObject=0);
742 // allocate task stack
743 void* AllocStack(uint32 auSize);
744 // reallocate task stack
745 void ReAllocStack(uint32 auSize);
746 // free task stack
747 void FreeStack();
748
750 virtual CINOSSync* GetSync();
752 virtual void SetCallResult(CMcResult aResult);
754 virtual CMcResult GetCallResult();
755
756 public:
761 void TLSAddData(struct STLSKeyData* apKeyData);
764 void TLSRemoveData(struct STLSKeyData* apKeyData);
765
766 #ifdef INOS_MULTICORE_KERNEL
770 struct SINOSCoreSync* GetCoreSync() { return m_pCoreSync; };
772 uint8 GetTaskCoreId() const { return m_uTaskCoreId; }
773 //** Set Id of CPU core this task has to run on.
774 void SetTaskCoreId(uint8 auCoreId)
783 { return m_uTaskCoreIdRequested; };
784 #else
786 struct SINOSCoreSync* GetCoreSync() { return nullptr; };
788 uint8 GetTaskCoreId() const { return 0; }
789 #endif
790 //** Set fieldbus category this task belongs to.
791 void SetTaskCategory(uint8 auCategory)
793 //** Get fieldbus category this task belongs to.
794 uint8 GetTaskCategory()
795 { return m_uTaskCategory; };
801 }
807 }
812 }
813
817 inline void EnableIrqDisableTiming() {
819 }
823 inline void DisableIrqDisableTiming() {
825 }
828 inline bool IsIrqDisableTimingEnabled() {
830 }
834 inline void EnablePriorityChecking() {
836 }
839 inline void DisablePriorityChecking() {
841 }
844 inline bool IsPriorityCheckingEnabled() {
846 }
850 inline void EnableSuspendTimingCheck() {
852 }
855 inline void DisableSuspendTimingCheck() {
857 }
860 inline bool IsSuspendTimingCheckEnabled() {
862 }
864 inline bool IsStartupDone() {
866 }
868 inline void EnableIncoTouch() {
870 }
872 inline void DisableIncoTouch() {
874 }
876 inline bool IsIncoTouchEnabled() {
877 return (m_uTskFlags & eTskFlgIncoTouch);
878 }
880 inline void EnableFloatingpoint() {
882 }
884 inline void DisableFloatingpoint() {
886 }
888 inline bool IsFloatingpointEnabled() {
890 }
892 void SetTskFlag(uint32 auFlag) {
894 }
895 /* \return Reference to the time stamp (in system ticks) when the
896 INOSDisableInterrupts() function has been called. The value is 0
897 if the function has not been called or if the INOSEnableInterrupts
898 has already been called again. */
899 inline uint32& GetIrqDisableTicks() {
900 return m_uIrqDisableTicks;
901 }
903 inline bool IsRealtime() {
904 return (m_eTskType == eTskTypeInterrupt) || ((m_eTskType == eTskTypeRealtime));
905 }
906
907 private:
911 mutable CINOSMutex m_TLSLock;
912 // call sync
914 // call result
915 CMcResult* m_pCallResult{};
916 // multi core sync
917 #ifdef INOS_MULTICORE_KERNEL
920 uint8 m_uTaskCoreId = GetCoreId();
923 #endif
925 uint8 m_uTaskCategory = 0xff;
926 // thread handle
927 #if defined(INOS_DESKTOP)
928 friend class CINOSKernel_desktop;
929 friend void _Suspend(uint32 auState, uint32 auFlags, CINOSTask* apTask);
930 friend void Resume(CINOSTask* apTask, uint32 auFlags);
931 friend void Relinquish();
932 friend void ChangePriority(uint32 auPriority);
933 std::thread* m_pThread = nullptr;
934 std::condition_variable_any m_Startup;
935 std::condition_variable_any m_Resume;
936 #endif
948 uint32 m_uIrqDisableTicks = 0;
949
951 uint32 m_uExitCode = 0;
953 CINOSSync* m_pShutdownDone = nullptr;
955 CINOSMutex m_ShutdownMutex = CINOSMutex(CINOSMutex::eFlgReclaimLock);
957 alignas(4) inosName128 m_cName = {0};
959 void* m_pFunctionParam = nullptr;
961 std::function<void(void*)> m_Function;
963 ETskType m_eTskType = eTskTypeSystem;
965 uint32 m_uReentrancyTouched{};
966
967 #if !defined(INOS_DESKTOP) && defined(INOS_THREADLOCAL)
969 uint8* m_pThreadLocal{};
970 uint8* m_pThreadLocalBase{};
971 #endif
972
974};
975
976//------------------------------------------------------------------------------
977//--- class CINOSTaskType ------------------------------------------------------
978//------------------------------------------------------------------------------
979
981{
982 //--- user interface ---------------------------------------------------
983
984 // public members
985 public :
991
996
997 //--- internals --------------------------------------------------------
998
999 // protected members
1000 protected :
1003};
1004
1005//------------------------------------------------------------------------------
1006// end of file
1007//------------------------------------------------------------------------------
1008
1009#endif // INC_INOSTASK_H
Definition cinostaskex.h:2713
Definition inos_syn.h:368
Definition inoskernel.h:239
Definition cinosmcmodule.h:1900
Definition inos_syn.h:235
Definition cinosmutex.h:36
Definition cinossiotftexp.h:731
Definition inos_syn.h:67
Definition cinostaskex.h:396
Definition cinostaskex.h:966
Definition cinostask.h:981
CINOSTaskType(CINOSTask::ETskType aeType)
Set task type to the requested value.
Definition cinostask.h:989
CINOSTask::ETskType m_eType
original type
Definition cinostask.h:1002
~CINOSTaskType()
Restore original type.
Definition cinostask.h:994
Definition cinostask.h:52
virtual void Exit()
Terminate myself. Exit code is INOS_OK or the code previously set with SetExitCode.
virtual ~CINOSTask()
Destroy task.
virtual void Exit(uint32 auExitCode)
Terminate myself.
INOS_INLINE ETskType SetTskType(ETskType aeType)
Set task type.
Definition cinostask.h:208
CINOSTask(const char *apName, std::function< void(void *)> aFunction, void *apParam=nullptr, uint8 auPriority=DF_INOS_TASK_PRIO_LOWEST)
Create a task with given properties. One needs to Resume the task after creation to get it running.
ETskType
Task types.
Definition cinostask.h:180
virtual uint32 Shutdown(CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
Shutdown task, used to shutdown a foreign task.
virtual void SetExitCode(uint32 auExitCode)
Set exit code.
Definition cinostask.h:135
virtual void ClrSuspendHook()
Clear Suspend hook.
Definition cinostask.h:166
INOS_INLINE ETskType GetTskType()
Get task type.
Definition cinostask.h:201
virtual uint32 GetExitCode()
Get exit code.
Definition cinostask.h:140
virtual void SetSuspendHook(void *apSuspendHook)
Set Suspend hook.
Definition cinostask.h:152
virtual bool CheckShutdown()
Check if a shutdown is pending.
Definition cinostask.h:146
virtual void Action()
Task action loop, needs to be overwritten by the user. For more info, see section Creation.
virtual void * GetSuspendHook()
Get Suspend hook if any.
Definition cinostask.h:173
CINOSTask(std::function< void(void *)> aFunction, void *apParam=nullptr, uint8 auPriority=DF_INOS_TASK_PRIO_LOWEST)
Create a task with given properties. One needs to Resume the task after creation to get it running.
CINOSTask(char *apName=nullptr, uint32 auStackSize=defDefaultStackSize, uint32 auPriority=DF_INOS_TASK_PRIO_LOWEST, bool abFloatingPoint=true, uint32 auTimeSlice=defDefaultTimeSlice, bool abInterruptsDisabled=false, void *apHandler=0, void *apObject=0)
Create a task with given properties. One needs to Resume the task after creation to get it running.
virtual uint32 Join()
Join task or in other words, wait till it terminates.
virtual void Detach()
Detach task from parent. One uses this method if one doesn't want this task to be shut down if the pa...
CINOSTask * ActualTask()
#define DF_INOS_TASK_PRIO_LOWEST
Definition inosdefine.h:187
#define INOS_INLINE
Definition inosdefine.h:60
#define DF_INOS_CORE_DEFAULT
Definition inosdefine.h:170
#define DF_INOS_SYNCHRONOUS
Definition inosmacro.h:332
Definition inostype.h:192