proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
DelayedDestruction.h
Go to the documentation of this file.
1
/*
2
* Copyright 2014-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <
folly/io/async/DelayedDestructionBase.h
>
20
21
#include <glog/logging.h>
22
23
namespace
folly
{
24
42
class
DelayedDestruction
:
public
DelayedDestructionBase
{
43
public
:
51
virtual
void
destroy
() {
52
// If guardCount_ is not 0, just set destroyPending_ to delay
53
// actual destruction.
54
if
(
getDestructorGuardCount
() != 0) {
55
destroyPending_
=
true
;
56
}
else
{
57
onDelayedDestroy
(
false
);
58
}
59
}
60
69
class
Destructor
{
70
public
:
71
void
operator()
(
DelayedDestruction
* dd)
const
{
72
dd->
destroy
();
73
}
74
};
75
76
bool
getDestroyPending
()
const
{
77
return
destroyPending_
;
78
}
79
80
protected
:
97
~DelayedDestruction
()
override
=
default
;
98
99
DelayedDestruction
() :
destroyPending_
(false) {}
100
101
private
:
109
bool
destroyPending_
;
110
111
void
onDelayedDestroy
(
bool
delayed)
override
{
112
// check if it is ok to destroy now
113
if
(delayed && !destroyPending_) {
114
return
;
115
}
116
destroyPending_ =
false
;
117
delete
this
;
118
}
119
};
120
}
// namespace folly
folly::DelayedDestruction::getDestroyPending
bool getDestroyPending() const
Definition:
DelayedDestruction.h:76
folly::DelayedDestruction::~DelayedDestruction
~DelayedDestruction() override=default
folly::DelayedDestructionBase::getDestructorGuardCount
uint32_t getDestructorGuardCount() const
Definition:
DelayedDestructionBase.h:202
folly::DelayedDestruction::Destructor::operator()
void operator()(DelayedDestruction *dd) const
Definition:
DelayedDestruction.h:71
folly
—— Concurrent Priority Queue Implementation ——
Definition:
AtomicBitSet.h:29
folly::DelayedDestruction::destroyPending_
bool destroyPending_
Definition:
DelayedDestruction.h:109
folly::DelayedDestructionBase
Definition:
DelayedDestructionBase.h:49
folly::DelayedDestruction::DelayedDestruction
DelayedDestruction()
Definition:
DelayedDestruction.h:99
DelayedDestructionBase.h
folly::DelayedDestruction::Destructor
Definition:
DelayedDestruction.h:69
folly::DelayedDestruction::onDelayedDestroy
void onDelayedDestroy(bool delayed) override
Definition:
DelayedDestruction.h:111
folly::DelayedDestruction::destroy
virtual void destroy()
Definition:
DelayedDestruction.h:51
folly::DelayedDestruction
Definition:
DelayedDestruction.h:42
proxygen
folly
folly
io
async
DelayedDestruction.h
Generated by
1.8.11