blob: d1ad2597a2e5f5cb5894dde8cfe36be516bf9bdb [file] [log] [blame]
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef __TASK_H__
#define __TASK_H__
#include "ErrorBase.h"
#include <vxWorks.h>
#include "Synchronized.h"
/**
* WPI task is a wrapper for a native VxWorks task.
*
* Some functions (documented) are guaranteed not to use any floating point so
* that it is safe to use them from tasks that do not have the VX_FP_TASK flag
* set (like during startup).
**/
class Task : public ErrorBase
{
public:
static const UINT32 kDefaultPriority = 101;
static const INT32 kInvalidTaskID = -1;
Task(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
virtual ~Task();
bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0,
UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0, UINT32 arg9 = 0);
bool Restart();
bool Stop();
bool IsReady();
bool IsSuspended();
bool Suspend();
bool Resume();
bool Verify();
INT32 GetPriority();
bool SetPriority(INT32 priority);
const char* GetName();
INT32 GetID();
private:
FUNCPTR m_function;
char* m_taskName;
INT32 m_taskID;
UINT32 m_stackSize;
INT32 m_priority;
ReentrantSemaphore m_prioritySemaphore;
bool HandleError(STATUS results);
DISALLOW_COPY_AND_ASSIGN(Task);
};
#endif // __TASK_H__