Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
dart::bin::DescriptorInfoMultipleMixin< DI > Class Template Reference

#include <eventhandler.h>

Inheritance diagram for dart::bin::DescriptorInfoMultipleMixin< DI >:

Public Member Functions

 DescriptorInfoMultipleMixin (intptr_t fd, bool disable_tokens)
 
virtual ~DescriptorInfoMultipleMixin ()
 
virtual bool IsListeningSocket () const
 
virtual void SetPortAndMask (Dart_Port port, intptr_t mask)
 
virtual void RemovePort (Dart_Port port)
 
virtual void RemoveAllPorts ()
 
virtual Dart_Port NextNotifyDartPort (intptr_t events_ready)
 
virtual void NotifyAllDartPorts (uintptr_t events)
 
virtual void ReturnTokens (Dart_Port port, int count)
 
virtual intptr_t Mask ()
 
virtual void Close ()
 

Detailed Description

template<typename DI>
class dart::bin::DescriptorInfoMultipleMixin< DI >

Definition at line 357 of file eventhandler.h.

Constructor & Destructor Documentation

◆ DescriptorInfoMultipleMixin()

template<typename DI >
dart::bin::DescriptorInfoMultipleMixin< DI >::DescriptorInfoMultipleMixin ( intptr_t  fd,
bool  disable_tokens 
)
inline

Definition at line 392 of file eventhandler.h.

393 : DI(fd),
394 tokens_map_(&SamePortValue, kTokenCount),
395 disable_tokens_(disable_tokens) {}

◆ ~DescriptorInfoMultipleMixin()

template<typename DI >
virtual dart::bin::DescriptorInfoMultipleMixin< DI >::~DescriptorInfoMultipleMixin ( )
inlinevirtual

Definition at line 397 of file eventhandler.h.

Member Function Documentation

◆ Close()

template<typename DI >
virtual void dart::bin::DescriptorInfoMultipleMixin< DI >::Close ( )
inlinevirtual

Definition at line 562 of file eventhandler.h.

562{ DI::Close(); }
void Close(PathBuilder *builder)
Definition: tessellator.cc:38

◆ IsListeningSocket()

template<typename DI >
virtual bool dart::bin::DescriptorInfoMultipleMixin< DI >::IsListeningSocket ( ) const
inlinevirtual

Definition at line 399 of file eventhandler.h.

399{ return true; }

◆ Mask()

template<typename DI >
virtual intptr_t dart::bin::DescriptorInfoMultipleMixin< DI >::Mask ( )
inlinevirtual

Definition at line 555 of file eventhandler.h.

555 {
556 if (active_readers_.HasHead()) {
557 return 1 << kInEvent;
558 }
559 return 0;
560 }

◆ NextNotifyDartPort()

template<typename DI >
virtual Dart_Port dart::bin::DescriptorInfoMultipleMixin< DI >::NextNotifyDartPort ( intptr_t  events_ready)
inlinevirtual

Definition at line 491 of file eventhandler.h.

491 {
492 // We're only sending `kInEvents` if there are multiple listeners (which is
493 // listening socktes).
494 ASSERT(IS_EVENT(events_ready, kInEvent) ||
495 IS_EVENT(events_ready, kDestroyedEvent));
496
497 if (active_readers_.HasHead()) {
498 PortEntry* pentry = reinterpret_cast<PortEntry*>(active_readers_.head());
499
500 // Update token count.
501 if (!disable_tokens_) {
502 pentry->token_count--;
503 }
504 if (pentry->token_count <= 0) {
505 active_readers_.RemoveHead();
506 } else {
507 active_readers_.Rotate();
508 }
509
510 return pentry->dart_port;
511 }
512 return 0;
513 }
void RemoveHead(ClearFun clear=nullptr)
Definition: eventhandler.h:138
#define ASSERT(E)
#define IS_EVENT(data, event_bit)
Definition: eventhandler.h:51
@ kDestroyedEvent
Definition: eventhandler.h:27

◆ NotifyAllDartPorts()

template<typename DI >
virtual void dart::bin::DescriptorInfoMultipleMixin< DI >::NotifyAllDartPorts ( uintptr_t  events)
inlinevirtual

Definition at line 515 of file eventhandler.h.

515 {
516 // Unexpected close, asynchronous destroy or error events are the only
517 // ones we broadcast to all listeners.
518 ASSERT(IS_EVENT(events, kCloseEvent) || IS_EVENT(events, kErrorEvent) ||
519 IS_EVENT(events, kDestroyedEvent));
520
521 for (SimpleHashMap::Entry* entry = tokens_map_.Start(); entry != nullptr;
522 entry = tokens_map_.Next(entry)) {
523 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
524 DartUtils::PostInt32(pentry->dart_port, events);
525
526 // Update token count.
527 bool was_ready = pentry->IsReady();
528 if (!disable_tokens_) {
529 pentry->token_count--;
530 }
531
532 if (was_ready && (pentry->token_count <= 0)) {
533 active_readers_.Remove(pentry);
534 }
535 }
536 }
Entry * Start() const
Definition: hashmap.cc:123
Entry * Next(Entry *p) const
Definition: hashmap.cc:127
static bool PostInt32(Dart_Port port_id, int32_t value)
Definition: dartutils.cc:672

◆ RemoveAllPorts()

template<typename DI >
virtual void dart::bin::DescriptorInfoMultipleMixin< DI >::RemoveAllPorts ( )
inlinevirtual

Definition at line 479 of file eventhandler.h.

479 {
480 for (SimpleHashMap::Entry* entry = tokens_map_.Start(); entry != nullptr;
481 entry = tokens_map_.Next(entry)) {
482 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
483 entry->value = nullptr;
484 active_readers_.Remove(pentry);
485 delete pentry;
486 }
487 tokens_map_.Clear();
488 active_readers_.RemoveAll(DeletePortEntry);
489 }
void Clear(ClearFun clear=nullptr)
Definition: hashmap.cc:111
void RemoveAll(ClearFun clear=nullptr)
Definition: eventhandler.h:185

◆ RemovePort()

template<typename DI >
virtual void dart::bin::DescriptorInfoMultipleMixin< DI >::RemovePort ( Dart_Port  port)
inlinevirtual

Definition at line 455 of file eventhandler.h.

455 {
456 SimpleHashMap::Entry* entry = tokens_map_.Lookup(
457 GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false);
458 if (entry != nullptr) {
459 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
460 if (pentry->IsReady()) {
461 active_readers_.Remove(pentry);
462 }
463 tokens_map_.Remove(GetHashmapKeyFromPort(port),
464 GetHashmapHashFromPort(port));
465 delete pentry;
466 } else {
467 // NOTE: This is a listening socket which has been immediately closed.
468 //
469 // If a listening socket is not listened on, the event handler does not
470 // know about it beforehand. So the first time the event handler knows
471 // about it, is when it is supposed to be closed. We therefore do nothing
472 // here.
473 //
474 // But whether to close it, depends on whether other isolates have it open
475 // as well or not.
476 }
477 }
Entry * Lookup(void *key, uint32_t hash, bool insert)
Definition: hashmap.cc:20
void Remove(void *key, uint32_t hash)
Definition: hashmap.cc:49
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
Definition: switches.h:87

◆ ReturnTokens()

template<typename DI >
virtual void dart::bin::DescriptorInfoMultipleMixin< DI >::ReturnTokens ( Dart_Port  port,
int  count 
)
inlinevirtual

Definition at line 538 of file eventhandler.h.

538 {
539 SimpleHashMap::Entry* entry = tokens_map_.Lookup(
540 GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false);
541 ASSERT(entry != nullptr);
542
543 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
544 bool was_ready = pentry->IsReady();
545 if (!disable_tokens_) {
546 pentry->token_count += count;
547 }
548 ASSERT(pentry->token_count <= kTokenCount);
549 bool is_ready = pentry->IsReady();
550 if (!was_ready && is_ready) {
551 active_readers_.Add(pentry);
552 }
553 }
int count
Definition: FontMgrTest.cpp:50

◆ SetPortAndMask()

template<typename DI >
virtual void dart::bin::DescriptorInfoMultipleMixin< DI >::SetPortAndMask ( Dart_Port  port,
intptr_t  mask 
)
inlinevirtual

Definition at line 401 of file eventhandler.h.

401 {
402 SimpleHashMap::Entry* entry = tokens_map_.Lookup(
403 GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), true);
404 PortEntry* pentry;
405 if (entry->value == nullptr) {
406 pentry = new PortEntry();
407 pentry->dart_port = port;
408 pentry->token_count = kTokenCount;
409 pentry->is_reading = IsReadingMask(mask);
410 entry->value = reinterpret_cast<void*>(pentry);
411
412 if (pentry->IsReady()) {
413 active_readers_.Add(pentry);
414 }
415 } else {
416 pentry = reinterpret_cast<PortEntry*>(entry->value);
417 bool was_ready = pentry->IsReady();
418 pentry->is_reading = IsReadingMask(mask);
419 bool is_ready = pentry->IsReady();
420
421 if (was_ready && !is_ready) {
422 active_readers_.Remove(pentry);
423 } else if (!was_ready && is_ready) {
424 active_readers_.Add(pentry);
425 }
426 }
427
428#ifdef DEBUG
429 // To ensure that all readers are ready.
430 int ready_count = 0;
431
432 if (active_readers_.HasHead()) {
433 PortEntry* root = reinterpret_cast<PortEntry*>(active_readers_.head());
434 PortEntry* current = root;
435 do {
436 ASSERT(current->IsReady());
437 ready_count++;
438 active_readers_.Rotate();
439 current = active_readers_.head();
440 } while (current != root);
441 }
442
443 for (SimpleHashMap::Entry* entry = tokens_map_.Start(); entry != nullptr;
444 entry = tokens_map_.Next(entry)) {
445 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
446 if (pentry->IsReady()) {
447 ready_count--;
448 }
449 }
450 // Ensure all ready items are in `active_readers_`.
451 ASSERT(ready_count == 0);
452#endif
453 }
string root
Definition: scale_cpu.py:20

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