blob: 4d770eafba91b74c7a46f77d07b722a5885dac51 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#ifndef __TASK_H__
8#define __TASK_H__
9
10#include "ErrorBase.h"
11#include <vxWorks.h>
12
13/**
14 * WPI task is a wrapper for the native Task object.
15 * All WPILib tasks are managed by a static task manager for simplified cleanup.
16 **/
17class Task : public ErrorBase
18{
19public:
20 static const UINT32 kDefaultPriority = 101;
21 static const INT32 kInvalidTaskID = -1;
22
23 Task(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
24 virtual ~Task();
25
26 bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0,
27 UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0, UINT32 arg9 = 0);
28 bool Restart();
29 bool Stop();
30
31 bool IsReady();
32 bool IsSuspended();
33
34 bool Suspend();
35 bool Resume();
36
37 bool Verify();
38
39 INT32 GetPriority();
40 bool SetPriority(INT32 priority);
41 const char* GetName();
42 INT32 GetID();
43
44private:
45 FUNCPTR m_function;
46 char* m_taskName;
47 INT32 m_taskID;
48 UINT32 m_stackSize;
49 INT32 m_priority;
50 bool HandleError(STATUS results);
51 DISALLOW_COPY_AND_ASSIGN(Task);
52};
53
54#endif // __TASK_H__