OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_EVENTHANDLER_H_ | 5 #ifndef BIN_EVENTHANDLER_H_ |
6 #define BIN_EVENTHANDLER_H_ | 6 #define BIN_EVENTHANDLER_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
10 #include "bin/isolate_data.h" | 10 #include "bin/isolate_data.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if (port_ != 0) { | 320 if (port_ != 0) { |
321 DartUtils::PostInt32(port_, events); | 321 DartUtils::PostInt32(port_, events); |
322 } | 322 } |
323 if (!disable_tokens_) { | 323 if (!disable_tokens_) { |
324 tokens_--; | 324 tokens_--; |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 virtual void ReturnTokens(Dart_Port port, int count) { | 328 virtual void ReturnTokens(Dart_Port port, int count) { |
329 ASSERT(port_ == port); | 329 ASSERT(port_ == port); |
330 ASSERT(tokens_ >= 0); | |
331 if (!disable_tokens_) { | 330 if (!disable_tokens_) { |
332 tokens_ += count; | 331 tokens_ += count; |
333 } | 332 } |
334 ASSERT(tokens_ <= kTokenCount); | 333 ASSERT(tokens_ <= kTokenCount); |
335 } | 334 } |
336 | 335 |
337 virtual intptr_t Mask() { | 336 virtual intptr_t Mask() { |
338 if (tokens_ <= 0) { | 337 if (tokens_ <= 0) { |
339 return 0; | 338 return 0; |
340 } | 339 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 540 } |
542 } | 541 } |
543 | 542 |
544 virtual void ReturnTokens(Dart_Port port, int count) { | 543 virtual void ReturnTokens(Dart_Port port, int count) { |
545 HashMap::Entry* entry = tokens_map_.Lookup( | 544 HashMap::Entry* entry = tokens_map_.Lookup( |
546 GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false); | 545 GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false); |
547 ASSERT(entry != NULL); | 546 ASSERT(entry != NULL); |
548 | 547 |
549 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value); | 548 PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value); |
550 bool was_ready = pentry->IsReady(); | 549 bool was_ready = pentry->IsReady(); |
551 ASSERT(pentry->token_count >= 0); | |
552 if (!disable_tokens_) { | 550 if (!disable_tokens_) { |
553 pentry->token_count += count; | 551 pentry->token_count += count; |
554 } | 552 } |
555 ASSERT(pentry->token_count <= kTokenCount); | 553 ASSERT(pentry->token_count <= kTokenCount); |
556 bool is_ready = pentry->token_count > 0 && pentry->IsReady(); | 554 bool is_ready = pentry->token_count > 0 && pentry->IsReady(); |
557 if (!was_ready && is_ready) { | 555 if (!was_ready && is_ready) { |
558 active_readers_.Add(pentry); | 556 active_readers_.Add(pentry); |
559 } | 557 } |
560 } | 558 } |
561 | 559 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 627 |
630 private: | 628 private: |
631 friend class EventHandlerImplementation; | 629 friend class EventHandlerImplementation; |
632 EventHandlerImplementation delegate_; | 630 EventHandlerImplementation delegate_; |
633 }; | 631 }; |
634 | 632 |
635 } // namespace bin | 633 } // namespace bin |
636 } // namespace dart | 634 } // namespace dart |
637 | 635 |
638 #endif // BIN_EVENTHANDLER_H_ | 636 #endif // BIN_EVENTHANDLER_H_ |
OLD | NEW |