blob: 4686c755f77eb11eef84968edee6db2acfc8162c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// -*- C++ -*-
//=============================================================================
/**
* @file Basic_P_Strategy.h
*
*
*
*
*
* @author Paul Oberlin <pauloberlin@gmail.com>
*/
//=============================================================================
#ifndef ACE_BASIC_P_STRATEGY_H
#define ACE_BASIC_P_STRATEGY_H
#include /**/ "ace/pre.h"
#include "ace/DA_Strategy_Base.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <typename AnnotationId>
class Basic_P_Strategy : public DA_Strategy_Base<AnnotationId> {
//The annotations consist of an identifier and a resource cost value
public:
Basic_P_Strategy(int maxThreads);
virtual ~Basic_P_Strategy();
virtual int is_deadlock_potential(AnnotationId handle);
virtual void grant(AnnotationId handle);
virtual void release(AnnotationId upcall_handle);
private:
int t_r;
};
ACE_END_VERSIONED_NAMESPACE_DECL
//#if defined (__ACE_INLINE__)
//#include "ace/Basic_P_Strategy.inl"
//#endif /* __ACE_INLINE__ */
template <typename AnnotationId>
ACE_INLINE
Basic_P_Strategy<AnnotationId>::Basic_P_Strategy(int maxThreads)
:DA_Strategy_Base<AnnotationId>(maxThreads),
t_r(maxThreads)
{
}
template <typename AnnotationId>
ACE_INLINE
Basic_P_Strategy<AnnotationId>::~Basic_P_Strategy()
{
}
template <typename AnnotationId>
ACE_INLINE
int Basic_P_Strategy<AnnotationId>::is_deadlock_potential(AnnotationId handle)
{
int annotation = get_annotation(handle);
if (annotation > t_r)
{
return annotation - t_r;
}
return 0;
}
template <typename AnnotationId>
ACE_INLINE
void Basic_P_Strategy<AnnotationId>::grant(AnnotationId handle)
{
--t_r;
}
template <typename AnnotationId>
ACE_INLINE
void Basic_P_Strategy<AnnotationId>::release(AnnotationId upcall_handle)
{
++t_r;
}
#include /**/ "ace/post.h"
#endif /* ACE_BASIC_P_STRATEGY_H */
|