The Pedigree Project
0.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
system
include
pedigree
kernel
utilities
TimeoutGuard.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2014, Pedigree Developers
3
*
4
* Please see the CONTRIB file in the root of the source tree for a full
5
* list of contributors.
6
*
7
* Permission to use, copy, modify, and distribute this software for any
8
* purpose with or without fee is hereby granted, provided that the above
9
* copyright notice and this permission notice appear in all copies.
10
*
11
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
*/
19
20
#ifndef TIMEOUT_GUARD_H
21
#define TIMEOUT_GUARD_H
22
29
#include "pedigree/kernel/Spinlock.h"
30
#include "pedigree/kernel/compiler.h"
31
#include "pedigree/kernel/process/Event.h"
32
#include "pedigree/kernel/process/eventNumbers.h"
33
#include "pedigree/kernel/processor/state.h"
34
#include "pedigree/kernel/processor/types.h"
35
45
class
EXPORTED_PUBLIC
TimeoutGuard
46
{
47
public
:
49
TimeoutGuard
(
size_t
timeoutSecs);
50
52
~
TimeoutGuard
();
53
56
bool
timedOut
()
57
{
58
return
m_bTimedOut;
59
}
60
63
void
cancel()
NORETURN
;
64
66
class
TimeoutGuardEvent
:
public
Event
67
{
68
public
:
69
TimeoutGuardEvent
() :
Event
(0,
false
), m_pTarget(0)
70
{
71
}
72
TimeoutGuardEvent
(
TimeoutGuard
*pTarget,
size_t
specificNestingLevel);
73
virtual
~
TimeoutGuardEvent
();
74
75
virtual
size_t
serialize(uint8_t *pBuffer);
76
static
bool
unserialize(uint8_t *pBuffer,
TimeoutGuardEvent
&event);
77
78
virtual
size_t
getNumber
()
79
{
80
return
EventNumbers::TimeoutGuard;
81
}
82
84
TimeoutGuard
*
m_pTarget
;
85
86
private
:
87
TimeoutGuardEvent
(
const
TimeoutGuardEvent
&);
88
TimeoutGuardEvent
&operator=(
const
TimeoutGuardEvent
&);
89
};
90
91
private
:
92
TimeoutGuard
(
const
TimeoutGuard
&);
93
TimeoutGuard
&operator=(
const
TimeoutGuard
&);
94
96
TimeoutGuardEvent
*
m_pEvent
;
97
99
bool
m_bTimedOut
;
100
102
#ifdef THREADS
103
SchedulerState
m_State
;
104
#else
105
void
*m_State;
106
#endif
107
109
size_t
m_nLevel
;
110
112
Spinlock
m_Lock
;
113
};
114
115
#endif
TimeoutGuard::m_Lock
Spinlock m_Lock
Definition:
TimeoutGuard.h:112
TimeoutGuard::m_nLevel
size_t m_nLevel
Definition:
TimeoutGuard.h:109
EXPORTED_PUBLIC
#define EXPORTED_PUBLIC
Definition:
system/include/pedigree/kernel/compiler.h:78
TimeoutGuard::TimeoutGuardEvent::getNumber
virtual size_t getNumber()
Definition:
TimeoutGuard.h:78
TimeoutGuard::m_pEvent
TimeoutGuardEvent * m_pEvent
Definition:
TimeoutGuard.h:96
TimeoutGuard::timedOut
bool timedOut()
Definition:
TimeoutGuard.h:56
TimeoutGuard::TimeoutGuardEvent
Definition:
TimeoutGuard.h:66
TimeoutGuard::m_State
SchedulerState m_State
Definition:
TimeoutGuard.h:103
TimeoutGuard::m_bTimedOut
bool m_bTimedOut
Definition:
TimeoutGuard.h:99
TimeoutGuard::TimeoutGuardEvent::m_pTarget
TimeoutGuard * m_pTarget
Definition:
TimeoutGuard.h:84
Spinlock
Definition:
Spinlock.h:27
TimeoutGuard
Definition:
TimeoutGuard.h:45
Event
Definition:
Event.h:48
NORETURN
#define NORETURN
Definition:
system/include/pedigree/kernel/compiler.h:35
Generated on Fri Jan 24 2020 06:49:08 for The Pedigree Project by
1.8.11