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
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark;
import javax.annotation.Nullable;
public class Impl {
static final String NO_TAG_NAME = "";
static final long NO_TAG_ID = Long.MIN_VALUE;
/**
* This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
* {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
*/
private static final long NO_LINK_ID = Long.MIN_VALUE;
static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
/** The Noop implementation */
protected Impl(Tag key) {
if (key != NO_TAG) {
throw new AssertionError("nope");
}
}
protected void setEnabled(boolean value) {}
protected boolean setEnabled(boolean value, boolean overload) {
return false;
}
protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
protected void startTask(String taskName, Tag tag) {}
protected void startTask(String taskName) {}
protected void startTask(String taskName, String subTaskName) {}
protected void event(String eventName, Tag tag) {}
protected void event(String eventName) {}
protected void event(String eventName, String subEventName) {}
protected void stopTask() {}
protected void stopTask(String taskName, Tag tag) {}
protected void stopTask(String taskName) {}
protected void stopTask(String taskName, String subTaskName) {}
protected Link linkOut() {
return NO_LINK;
}
protected void linkIn(Link link) {}
protected void attachTag(Tag tag) {}
protected void attachTag(String tagName, String tagValue) {}
protected void attachTag(String tagName, long tagValue) {}
protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
protected <T> void attachTag(
String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
protected Tag createTag(@Nullable String tagName, long tagId) {
return NO_TAG;
}
@Nullable
protected static String unpackTagName(Tag tag) {
return tag.tagName;
}
protected static long unpackTagId(Tag tag) {
return tag.tagId;
}
protected static long unpackLinkId(Link link) {
return link.linkId;
}
protected static Tag packTag(@Nullable String tagName, long tagId) {
return new Tag(tagName, tagId);
}
protected static Link packLink(long linkId) {
return new Link(linkId);
}
}
|