Flutter Engine
The Flutter Engine
Static Public Member Functions | Static Public Attributes | List of all members
dart::UserTags Class Reference

#include <tags.h>

Inheritance diagram for dart::UserTags:
dart::AllStatic

Static Public Member Functions

static const char * TagName (uword tag_id)
 
static bool IsUserTag (uword tag_id)
 
static void AddStreamableTagName (const char *tag)
 
static void RemoveStreamableTagName (const char *tag)
 
static bool IsTagNameStreamable (const char *tag)
 
static void Init ()
 
static void Cleanup ()
 

Static Public Attributes

static constexpr intptr_t kMaxUserTags = 256
 
static constexpr uword kUserTagIdOffset = 0x4096
 
static constexpr uword kDefaultUserTag = kUserTagIdOffset
 

Detailed Description

Definition at line 107 of file tags.h.

Member Function Documentation

◆ AddStreamableTagName()

void dart::UserTags::AddStreamableTagName ( const char *  tag)
static

Definition at line 152 of file tags.cc.

152 {
153 MutexLocker ml(subscribed_tags_lock_);
154 // Check this tag isn't already in the subscription list.
155 for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
156 if (strcmp(tag, subscribed_tags_.At(i)) == 0) {
157 return;
158 }
159 }
160 subscribed_tags_.Add(Utils::StrDup(tag));
161}
void Add(const T &value)
const T & At(intptr_t index) const
intptr_t length() const
static char * StrDup(const char *s)

◆ Cleanup()

void dart::UserTags::Cleanup ( )
static

Definition at line 191 of file tags.cc.

191 {
192 {
193 MutexLocker ml(subscribed_tags_lock_);
194 for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
195 free(const_cast<char*>(subscribed_tags_.At(i)));
196 }
197 subscribed_tags_.Clear();
198 }
199 delete subscribed_tags_lock_;
200 subscribed_tags_lock_ = nullptr;
201}

◆ Init()

void dart::UserTags::Init ( )
static

Definition at line 187 of file tags.cc.

187 {
188 subscribed_tags_lock_ = new Mutex();
189}

◆ IsTagNameStreamable()

bool dart::UserTags::IsTagNameStreamable ( const char *  tag)
static

Definition at line 177 of file tags.cc.

177 {
178 MutexLocker ml(subscribed_tags_lock_);
179 for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
180 if (strcmp(tag, subscribed_tags_.At(i)) == 0) {
181 return true;
182 }
183 }
184 return false;
185}

◆ IsUserTag()

static bool dart::UserTags::IsUserTag ( uword  tag_id)
inlinestatic

Definition at line 114 of file tags.h.

114 {
115 return (tag_id >= kUserTagIdOffset) &&
116 (tag_id < kUserTagIdOffset + kMaxUserTags);
117 }
static constexpr intptr_t kMaxUserTags
Definition: tags.h:110
static constexpr uword kUserTagIdOffset
Definition: tags.h:111

◆ RemoveStreamableTagName()

void dart::UserTags::RemoveStreamableTagName ( const char *  tag)
static

Definition at line 163 of file tags.cc.

163 {
164 MutexLocker ml(subscribed_tags_lock_);
165 bool found = false;
166 for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
167 if (strcmp(tag, subscribed_tags_.At(i)) == 0) {
168 free(const_cast<char*>(subscribed_tags_.At(i)));
169 subscribed_tags_.RemoveAt(i);
170 found = true;
171 break;
172 }
173 }
174 ASSERT(found);
175}
void RemoveAt(intptr_t i)
#define ASSERT(E)

◆ TagName()

const char * dart::UserTags::TagName ( uword  tag_id)
static

Definition at line 139 of file tags.cc.

139 {
140 ASSERT(tag_id >= kUserTagIdOffset);
142 const Thread* thread = Thread::Current();
143 Zone* zone = thread->zone();
144 Isolate* isolate = thread->isolate();
145 const UserTag& tag =
146 UserTag::Handle(zone, UserTag::FindTagById(isolate, tag_id));
147 ASSERT(!tag.IsNull());
148 const String& label = String::Handle(zone, tag.label());
149 return label.ToCString();
150}
static Object & Handle()
Definition: object.h:407
static Thread * Current()
Definition: thread.h:362
static UserTagPtr FindTagById(const Isolate *isolate, uword tag_id)
Definition: object.cc:27053

Member Data Documentation

◆ kDefaultUserTag

constexpr uword dart::UserTags::kDefaultUserTag = kUserTagIdOffset
staticconstexpr

Definition at line 112 of file tags.h.

◆ kMaxUserTags

constexpr intptr_t dart::UserTags::kMaxUserTags = 256
staticconstexpr

Definition at line 110 of file tags.h.

◆ kUserTagIdOffset

constexpr uword dart::UserTags::kUserTagIdOffset = 0x4096
staticconstexpr

Definition at line 111 of file tags.h.


The documentation for this class was generated from the following files: