WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Resource.h
1 /*----------------------------------------------------------------------------*/
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 RESOURCE_H_
8 #define RESOURCE_H_
9 
10 #include "ErrorBase.h"
11 #include "Synchronized.h"
12 #include <vxWorks.h>
13 
23 class Resource : public ErrorBase
24 {
25 public:
26  virtual ~Resource();
27  static void CreateResourceObject(Resource **r, uint32_t elements);
28  uint32_t Allocate(const char *resourceDesc);
29  uint32_t Allocate(uint32_t index, const char *resourceDesc);
30  void Free(uint32_t index);
31 
32 private:
33  explicit Resource(uint32_t size);
34 
35  bool *m_isAllocated;
36  ReentrantSemaphore m_allocateLock;
37  uint32_t m_size;
38 
39  static ReentrantSemaphore m_createLock;
40 
41  DISALLOW_COPY_AND_ASSIGN(Resource);
42 };
43 
44 #endif
uint32_t Allocate(const char *resourceDesc)
Definition: Resource.cpp:62
static void CreateResourceObject(Resource **r, uint32_t elements)
Definition: Resource.cpp:39
virtual ~Resource()
Definition: Resource.cpp:52
Definition: ErrorBase.h:37
Definition: Resource.h:23
void Free(uint32_t index)
Definition: Resource.cpp:105
Definition: Synchronized.h:31