Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: net/tools/epoll_server/epoll_server.h

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/dump_cache/dump_files.cc ('k') | net/tools/epoll_server/epoll_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ 5 #ifndef NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_
6 #define NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ 6 #define NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_
7 7
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h>
10 #include <stdint.h>
9 #include <sys/queue.h> 11 #include <sys/queue.h>
12
10 #include <map> 13 #include <map>
11 #include <string> 14 #include <string>
12 #include <vector> 15 #include <vector>
13 16
14 // #define EPOLL_SERVER_EVENT_TRACING 1 17 // #define EPOLL_SERVER_EVENT_TRACING 1
15 // 18 //
16 // Defining EPOLL_SERVER_EVENT_TRACING 19 // Defining EPOLL_SERVER_EVENT_TRACING
17 // causes code to exist which didn't before. 20 // causes code to exist which didn't before.
18 // This code tracks each event generated by the epollserver, 21 // This code tracks each event generated by the epollserver,
19 // as well as providing a per-fd-registered summary of 22 // as well as providing a per-fd-registered summary of
20 // events. Note that enabling this code vastly slows 23 // events. Note that enabling this code vastly slows
21 // down operations, and uses substantially more 24 // down operations, and uses substantially more
22 // memory. For these reasons, it should only be enabled by developers doing 25 // memory. For these reasons, it should only be enabled by developers doing
23 // development at their workstations. 26 // development at their workstations.
24 // 27 //
25 // A structure called 'EventRecorder' will exist when 28 // A structure called 'EventRecorder' will exist when
26 // the macro is defined. See the EventRecorder class interface 29 // the macro is defined. See the EventRecorder class interface
27 // within the EpollServer class for more details. 30 // within the EpollServer class for more details.
28 #ifdef EPOLL_SERVER_EVENT_TRACING 31 #ifdef EPOLL_SERVER_EVENT_TRACING
29 #include <ostream> 32 #include <ostream>
30 #include "base/logging.h" 33 #include "base/logging.h"
31 #endif 34 #endif
32 35
33 #include "base/basictypes.h"
34 #include "base/compiler_specific.h" 36 #include "base/compiler_specific.h"
35 #include "base/containers/hash_tables.h" 37 #include "base/containers/hash_tables.h"
38 #include "base/macros.h"
36 #include "base/memory/scoped_ptr.h" 39 #include "base/memory/scoped_ptr.h"
37 #include <sys/epoll.h> 40 #include <sys/epoll.h>
38 41
39 namespace net { 42 namespace net {
40 43
41 class EpollServer; 44 class EpollServer;
42 class EpollAlarmCallbackInterface; 45 class EpollAlarmCallbackInterface;
43 class ReadPipeCallback; 46 class ReadPipeCallback;
44 47
45 struct EpollEvent { 48 struct EpollEvent {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 }; 116 };
114 117
115 //////////////////////////////////////////////////////////////////////////////// 118 ////////////////////////////////////////////////////////////////////////////////
116 //////////////////////////////////////////////////////////////////////////////// 119 ////////////////////////////////////////////////////////////////////////////////
117 120
118 class EpollServer { 121 class EpollServer {
119 public: 122 public:
120 typedef EpollAlarmCallbackInterface AlarmCB; 123 typedef EpollAlarmCallbackInterface AlarmCB;
121 typedef EpollCallbackInterface CB; 124 typedef EpollCallbackInterface CB;
122 125
123 typedef std::multimap<int64, AlarmCB*> TimeToAlarmCBMap; 126 typedef std::multimap<int64_t, AlarmCB*> TimeToAlarmCBMap;
124 typedef TimeToAlarmCBMap::iterator AlarmRegToken; 127 typedef TimeToAlarmCBMap::iterator AlarmRegToken;
125 128
126 // Summary: 129 // Summary:
127 // Constructor: 130 // Constructor:
128 // By default, we don't wait any amount of time for events, and 131 // By default, we don't wait any amount of time for events, and
129 // we suggest to the epoll-system that we're going to use on-the-order 132 // we suggest to the epoll-system that we're going to use on-the-order
130 // of 1024 FDs. 133 // of 1024 FDs.
131 EpollServer(); 134 EpollServer();
132 135
133 //////////////////////////////////////// 136 ////////////////////////////////////////
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // If the callback returns a positive number from its OnAlarm() function, 355 // If the callback returns a positive number from its OnAlarm() function,
353 // then the callback will be re-registered at that time, else the alarm 356 // then the callback will be re-registered at that time, else the alarm
354 // owner is responsible for freeing up memory. 357 // owner is responsible for freeing up memory.
355 // 358 //
356 // Important: A give AlarmCB* can not be registered again if it is already 359 // Important: A give AlarmCB* can not be registered again if it is already
357 // registered. If a user wants to register a callback again it should first 360 // registered. If a user wants to register a callback again it should first
358 // unregister the previous callback before calling RegisterAlarm again. 361 // unregister the previous callback before calling RegisterAlarm again.
359 // Args: 362 // Args:
360 // timeout_time_in_us - the absolute time at which the alarm should go off 363 // timeout_time_in_us - the absolute time at which the alarm should go off
361 // ac - the alarm which will be called. 364 // ac - the alarm which will be called.
362 virtual void RegisterAlarm(int64 timeout_time_in_us, AlarmCB* ac); 365 virtual void RegisterAlarm(int64_t timeout_time_in_us, AlarmCB* ac);
363 366
364 // Summary: 367 // Summary:
365 // Registers an alarm 'ac' to go off at time: (ApproximateNowInUs() + 368 // Registers an alarm 'ac' to go off at time: (ApproximateNowInUs() +
366 // delta_in_us). While this is somewhat less accurate (see the description 369 // delta_in_us). While this is somewhat less accurate (see the description
367 // for ApproximateNowInUs() to see how 'approximate'), the error is never 370 // for ApproximateNowInUs() to see how 'approximate'), the error is never
368 // worse than the amount of time it takes to process all events in one 371 // worse than the amount of time it takes to process all events in one
369 // WaitForEvents. As with 'RegisterAlarm()', if the callback returns a 372 // WaitForEvents. As with 'RegisterAlarm()', if the callback returns a
370 // positive number from its OnAlarm() function, then the callback will be 373 // positive number from its OnAlarm() function, then the callback will be
371 // re-registered at that time, else the alarm owner is responsible for 374 // re-registered at that time, else the alarm owner is responsible for
372 // freeing up memory. 375 // freeing up memory.
373 // Note that this function is purely a convienence. The 376 // Note that this function is purely a convienence. The
374 // same thing may be accomplished by using RegisterAlarm with 377 // same thing may be accomplished by using RegisterAlarm with
375 // ApproximateNowInUs() directly. 378 // ApproximateNowInUs() directly.
376 // 379 //
377 // Important: A give AlarmCB* can not be registered again if it is already 380 // Important: A give AlarmCB* can not be registered again if it is already
378 // registered. If a user wants to register a callback again it should first 381 // registered. If a user wants to register a callback again it should first
379 // unregister the previous callback before calling RegisterAlarm again. 382 // unregister the previous callback before calling RegisterAlarm again.
380 // Args: 383 // Args:
381 // delta_in_us - the delta in microseconds from the ApproximateTimeInUs() at 384 // delta_in_us - the delta in microseconds from the ApproximateTimeInUs() at
382 // which point the alarm should go off. 385 // which point the alarm should go off.
383 // ac - the alarm which will be called. 386 // ac - the alarm which will be called.
384 void RegisterAlarmApproximateDelta(int64 delta_in_us, AlarmCB* ac) { 387 void RegisterAlarmApproximateDelta(int64_t delta_in_us, AlarmCB* ac) {
385 RegisterAlarm(ApproximateNowInUsec() + delta_in_us, ac); 388 RegisterAlarm(ApproximateNowInUsec() + delta_in_us, ac);
386 } 389 }
387 390
388 //////////////////////////////////////// 391 ////////////////////////////////////////
389 392
390 // Summary: 393 // Summary:
391 // Unregister the alarm referred to by iterator_token; Callers should 394 // Unregister the alarm referred to by iterator_token; Callers should
392 // be warned that a token may have become already invalid when OnAlarm() 395 // be warned that a token may have become already invalid when OnAlarm()
393 // is called, was unregistered, or OnShutdown was called on that alarm. 396 // is called, was unregistered, or OnShutdown was called on that alarm.
394 // Args: 397 // Args:
(...skipping 12 matching lines...) Expand all
407 // Summary: 410 // Summary:
408 // Force the epoll server to wake up (by writing to an internal pipe). 411 // Force the epoll server to wake up (by writing to an internal pipe).
409 virtual void Wake(); 412 virtual void Wake();
410 413
411 // Summary: 414 // Summary:
412 // Wrapper around WallTimer's NowInUsec. We do this so that we can test 415 // Wrapper around WallTimer's NowInUsec. We do this so that we can test
413 // EpollServer without using the system clock (and can avoid the flakiness 416 // EpollServer without using the system clock (and can avoid the flakiness
414 // that would ensue) 417 // that would ensue)
415 // Returns: 418 // Returns:
416 // the current time as number of microseconds since the Unix epoch. 419 // the current time as number of microseconds since the Unix epoch.
417 virtual int64 NowInUsec() const; 420 virtual int64_t NowInUsec() const;
418 421
419 // Summary: 422 // Summary:
420 // Since calling NowInUsec() many thousands of times per 423 // Since calling NowInUsec() many thousands of times per
421 // WaitForEventsAndExecuteCallbacks function call is, to say the least, 424 // WaitForEventsAndExecuteCallbacks function call is, to say the least,
422 // inefficient, we allow users to use an approximate time instead. The 425 // inefficient, we allow users to use an approximate time instead. The
423 // time returned from this function is as accurate as NowInUsec() when 426 // time returned from this function is as accurate as NowInUsec() when
424 // WaitForEventsAndExecuteCallbacks is not an ancestor of the caller's 427 // WaitForEventsAndExecuteCallbacks is not an ancestor of the caller's
425 // callstack. 428 // callstack.
426 // However, when WaitForEventsAndExecuteCallbacks -is- an ancestor, then 429 // However, when WaitForEventsAndExecuteCallbacks -is- an ancestor, then
427 // this function returns the time at which the 430 // this function returns the time at which the
428 // WaitForEventsAndExecuteCallbacks function started to process events or 431 // WaitForEventsAndExecuteCallbacks function started to process events or
429 // alarms. 432 // alarms.
430 // 433 //
431 // Essentially, this function makes available a fast and mostly accurate 434 // Essentially, this function makes available a fast and mostly accurate
432 // mechanism for getting the time for any function handling an event or 435 // mechanism for getting the time for any function handling an event or
433 // alarm. When functions which are not handling callbacks or alarms call 436 // alarm. When functions which are not handling callbacks or alarms call
434 // this function, they get the slow and "absolutely" accurate time. 437 // this function, they get the slow and "absolutely" accurate time.
435 // 438 //
436 // Users should be encouraged to use this function. 439 // Users should be encouraged to use this function.
437 // Returns: 440 // Returns:
438 // the "approximate" current time as number of microseconds since the Unix 441 // the "approximate" current time as number of microseconds since the Unix
439 // epoch. 442 // epoch.
440 virtual int64 ApproximateNowInUsec() const; 443 virtual int64_t ApproximateNowInUsec() const;
441 444
442 static std::string EventMaskToString(int event_mask); 445 static std::string EventMaskToString(int event_mask);
443 446
444 // Summary: 447 // Summary:
445 // Logs the state of the epoll server with LOG(ERROR). 448 // Logs the state of the epoll server with LOG(ERROR).
446 void LogStateOnCrash(); 449 void LogStateOnCrash();
447 450
448 // Summary: 451 // Summary:
449 // Set the timeout to the value specified. 452 // Set the timeout to the value specified.
450 // If the timeout is set to a negative number, 453 // If the timeout is set to a negative number,
451 // WaitForEventsAndExecuteCallbacks() will only return when an event has 454 // WaitForEventsAndExecuteCallbacks() will only return when an event has
452 // occured 455 // occured
453 // If the timeout is set to zero, 456 // If the timeout is set to zero,
454 // WaitForEventsAndExecuteCallbacks() will return immediately 457 // WaitForEventsAndExecuteCallbacks() will return immediately
455 // If the timeout is set to a positive number, 458 // If the timeout is set to a positive number,
456 // WaitForEventsAndExecuteCallbacks() will return when an event has 459 // WaitForEventsAndExecuteCallbacks() will return when an event has
457 // occured, or when timeout_in_us microseconds has elapsed, whichever 460 // occured, or when timeout_in_us microseconds has elapsed, whichever
458 // is first. 461 // is first.
459 // Args: 462 // Args:
460 // timeout_in_us - value specified depending on behaviour desired. 463 // timeout_in_us - value specified depending on behaviour desired.
461 // See above. 464 // See above.
462 void set_timeout_in_us(int64 timeout_in_us) { 465 void set_timeout_in_us(int64_t timeout_in_us) {
463 timeout_in_us_ = timeout_in_us; 466 timeout_in_us_ = timeout_in_us;
464 } 467 }
465 468
466 //////////////////////////////////////// 469 ////////////////////////////////////////
467 470
468 // Summary: 471 // Summary:
469 // Accessor for the current value of timeout_in_us. 472 // Accessor for the current value of timeout_in_us.
470 int timeout_in_us() const { return timeout_in_us_; } 473 int timeout_in_us() const { return timeout_in_us_; }
471 474
472 // Summary: 475 // Summary:
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 618
616 //////////////////////////////////////// 619 ////////////////////////////////////////
617 620
618 // Summary: 621 // Summary:
619 // Waits for events, and calls HandleEvents() for each 622 // Waits for events, and calls HandleEvents() for each
620 // fd, event pair discovered to possibly have an event. 623 // fd, event pair discovered to possibly have an event.
621 // Note that a callback (B) may get a spurious event if 624 // Note that a callback (B) may get a spurious event if
622 // another callback (A) has closed a file-descriptor N, and 625 // another callback (A) has closed a file-descriptor N, and
623 // the callback (B) has a newly opened file-descriptor, which 626 // the callback (B) has a newly opened file-descriptor, which
624 // also happens to be N. 627 // also happens to be N.
625 virtual void WaitForEventsAndCallHandleEvents(int64 timeout_in_us, 628 virtual void WaitForEventsAndCallHandleEvents(int64_t timeout_in_us,
626 struct epoll_event events[], 629 struct epoll_event events[],
627 int events_size); 630 int events_size);
628 631
629
630
631 // Summary: 632 // Summary:
632 // An internal function for implementing the ready list. It adds a fd's 633 // An internal function for implementing the ready list. It adds a fd's
633 // CBAndEventMask to the ready list. If the fd is already on the ready 634 // CBAndEventMask to the ready list. If the fd is already on the ready
634 // list, it is a no-op. 635 // list, it is a no-op.
635 void AddToReadyList(CBAndEventMask* cb_and_mask); 636 void AddToReadyList(CBAndEventMask* cb_and_mask);
636 637
637 // Summary: 638 // Summary:
638 // An internal function for implementing the ready list. It remove a fd's 639 // An internal function for implementing the ready list. It remove a fd's
639 // CBAndEventMask from the ready list. If the fd is not on the ready list, 640 // CBAndEventMask from the ready list. If the fd is not on the ready list,
640 // it is a no-op. 641 // it is a no-op.
(...skipping 25 matching lines...) Expand all
666 typedef base::hash_set<AlarmCB*, AlarmCBHash> AlarmCBMap; 667 typedef base::hash_set<AlarmCB*, AlarmCBHash> AlarmCBMap;
667 AlarmCBMap all_alarms_; 668 AlarmCBMap all_alarms_;
668 669
669 TimeToAlarmCBMap alarm_map_; 670 TimeToAlarmCBMap alarm_map_;
670 671
671 // The amount of time in microseconds that we'll wait before returning 672 // The amount of time in microseconds that we'll wait before returning
672 // from the WaitForEventsAndExecuteCallbacks() function. 673 // from the WaitForEventsAndExecuteCallbacks() function.
673 // If this is positive, wait that many microseconds. 674 // If this is positive, wait that many microseconds.
674 // If this is negative, wait forever, or for the first event that occurs 675 // If this is negative, wait forever, or for the first event that occurs
675 // If this is zero, never wait for an event. 676 // If this is zero, never wait for an event.
676 int64 timeout_in_us_; 677 int64_t timeout_in_us_;
677 678
678 // This is nonzero only after the invocation of epoll_wait_impl within 679 // This is nonzero only after the invocation of epoll_wait_impl within
679 // WaitForEventsAndCallHandleEvents and before the function 680 // WaitForEventsAndCallHandleEvents and before the function
680 // WaitForEventsAndExecuteCallbacks returns. At all other times, this is 681 // WaitForEventsAndExecuteCallbacks returns. At all other times, this is
681 // zero. This enables us to have relatively accurate time returned from the 682 // zero. This enables us to have relatively accurate time returned from the
682 // ApproximateNowInUs() function. See that function for more details. 683 // ApproximateNowInUs() function. See that function for more details.
683 int64 recorded_now_in_us_; 684 int64_t recorded_now_in_us_;
684 685
685 // This is used to implement CallAndReregisterAlarmEvents. This stores 686 // This is used to implement CallAndReregisterAlarmEvents. This stores
686 // all alarms that were reregistered because OnAlarm() returned a 687 // all alarms that were reregistered because OnAlarm() returned a
687 // value > 0 and the time at which they should be executed is less that 688 // value > 0 and the time at which they should be executed is less that
688 // the current time. By storing such alarms in this map we ensure 689 // the current time. By storing such alarms in this map we ensure
689 // that while calling CallAndReregisterAlarmEvents we do not call 690 // that while calling CallAndReregisterAlarmEvents we do not call
690 // OnAlarm on any alarm in this set. This ensures that we do not 691 // OnAlarm on any alarm in this set. This ensures that we do not
691 // go in an infinite loop. 692 // go in an infinite loop.
692 AlarmCBMap alarms_reregistered_and_should_be_skipped_; 693 AlarmCBMap alarms_reregistered_and_should_be_skipped_;
693 694
(...skipping 16 matching lines...) Expand all
710 // When a number of events equals the record threshold, 711 // When a number of events equals the record threshold,
711 // the collected data summary for all FDs will be written 712 // the collected data summary for all FDs will be written
712 // to LOG(INFO). Note that this does not include the 713 // to LOG(INFO). Note that this does not include the
713 // individual events (if you'reinterested in those, you'll 714 // individual events (if you'reinterested in those, you'll
714 // have to get at them programmatically). 715 // have to get at them programmatically).
715 // After any such flushing to LOG(INFO) all events will 716 // After any such flushing to LOG(INFO) all events will
716 // be cleared. 717 // be cleared.
717 // Note that the definition of an 'event' is a bit 'hazy', 718 // Note that the definition of an 'event' is a bit 'hazy',
718 // as it includes the 'Unregistration' event, and perhaps 719 // as it includes the 'Unregistration' event, and perhaps
719 // others. 720 // others.
720 void set_record_threshold(int64 new_threshold) { 721 void set_record_threshold(int64_t new_threshold) {
721 record_threshold_ = new_threshold; 722 record_threshold_ = new_threshold;
722 } 723 }
723 724
724 void Clear() { 725 void Clear() {
725 for (int i = 0; i < debug_events_.size(); ++i) { 726 for (int i = 0; i < debug_events_.size(); ++i) {
726 delete debug_events_[i]; 727 delete debug_events_[i];
727 } 728 }
728 debug_events_.clear(); 729 debug_events_.clear();
729 unregistered_fds_.clear(); 730 unregistered_fds_.clear();
730 event_counts_.clear(); 731 event_counts_.clear();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 unsigned int epoll_err; 910 unsigned int epoll_err;
910 unsigned int epoll_hup; 911 unsigned int epoll_hup;
911 unsigned int epoll_oneshot; 912 unsigned int epoll_oneshot;
912 unsigned int epoll_et; 913 unsigned int epoll_et;
913 }; 914 };
914 915
915 std::vector<DebugOutput*> debug_events_; 916 std::vector<DebugOutput*> debug_events_;
916 std::vector<Events> unregistered_fds_; 917 std::vector<Events> unregistered_fds_;
917 typedef base::hash_map<int, Events> EventCountsMap; 918 typedef base::hash_map<int, Events> EventCountsMap;
918 EventCountsMap event_counts_; 919 EventCountsMap event_counts_;
919 int64 num_records_; 920 int64_t num_records_;
920 int64 record_threshold_; 921 int64_t record_threshold_;
921 }; 922 };
922 923
923 void ClearEventRecords() { 924 void ClearEventRecords() {
924 event_recorder_.Clear(); 925 event_recorder_.Clear();
925 } 926 }
926 void WriteEventRecords(ostream* os) const { 927 void WriteEventRecords(ostream* os) const {
927 (*os) << event_recorder_; 928 (*os) << event_recorder_;
928 } 929 }
929 930
930 mutable EventRecorder event_recorder_; 931 mutable EventRecorder event_recorder_;
(...skipping 30 matching lines...) Expand all
961 962
962 class EpollAlarmCallbackInterface { 963 class EpollAlarmCallbackInterface {
963 public: 964 public:
964 // Summary: 965 // Summary:
965 // Called when an alarm times out. Invalidates an AlarmRegToken. 966 // Called when an alarm times out. Invalidates an AlarmRegToken.
966 // WARNING: If a token was saved to refer to an alarm callback, OnAlarm must 967 // WARNING: If a token was saved to refer to an alarm callback, OnAlarm must
967 // delete it, as the reference is no longer valid. 968 // delete it, as the reference is no longer valid.
968 // Returns: 969 // Returns:
969 // the unix time (in microseconds) at which this alarm should be signaled 970 // the unix time (in microseconds) at which this alarm should be signaled
970 // again, or 0 if the alarm should be removed. 971 // again, or 0 if the alarm should be removed.
971 virtual int64 OnAlarm() = 0; 972 virtual int64_t OnAlarm() = 0;
972 973
973 // Summary: 974 // Summary:
974 // Called when the an alarm is registered. Invalidates an AlarmRegToken. 975 // Called when the an alarm is registered. Invalidates an AlarmRegToken.
975 // Args: 976 // Args:
976 // token: the iterator to the the alarm registered in the alarm map. 977 // token: the iterator to the the alarm registered in the alarm map.
977 // WARNING: this token becomes invalid when the alarm fires, is 978 // WARNING: this token becomes invalid when the alarm fires, is
978 // unregistered, or OnShutdown is called on that alarm. 979 // unregistered, or OnShutdown is called on that alarm.
979 // eps: the epoll server the alarm is registered with. 980 // eps: the epoll server the alarm is registered with.
980 virtual void OnRegistration(const EpollServer::AlarmRegToken& token, 981 virtual void OnRegistration(const EpollServer::AlarmRegToken& token,
981 EpollServer* eps) = 0; 982 EpollServer* eps) = 0;
(...skipping 23 matching lines...) Expand all
1005 // of the parent class, or is must otherwise make sure that the 'registered_' 1006 // of the parent class, or is must otherwise make sure that the 'registered_'
1006 // boolean and the token, 'token_', are updated appropriately. 1007 // boolean and the token, 'token_', are updated appropriately.
1007 class EpollAlarm : public EpollAlarmCallbackInterface { 1008 class EpollAlarm : public EpollAlarmCallbackInterface {
1008 public: 1009 public:
1009 EpollAlarm(); 1010 EpollAlarm();
1010 1011
1011 ~EpollAlarm() override; 1012 ~EpollAlarm() override;
1012 1013
1013 // Marks the alarm as unregistered and returns 0. The return value may be 1014 // Marks the alarm as unregistered and returns 0. The return value may be
1014 // safely ignored by subclasses. 1015 // safely ignored by subclasses.
1015 int64 OnAlarm() override; 1016 int64_t OnAlarm() override;
1016 1017
1017 // Marks the alarm as registered, and stores the token. 1018 // Marks the alarm as registered, and stores the token.
1018 void OnRegistration(const EpollServer::AlarmRegToken& token, 1019 void OnRegistration(const EpollServer::AlarmRegToken& token,
1019 EpollServer* eps) override; 1020 EpollServer* eps) override;
1020 1021
1021 // Marks the alarm as unregistered. 1022 // Marks the alarm as unregistered.
1022 void OnUnregistration() override; 1023 void OnUnregistration() override;
1023 1024
1024 // Marks the alarm as unregistered. 1025 // Marks the alarm as unregistered.
1025 void OnShutdown(EpollServer* eps) override; 1026 void OnShutdown(EpollServer* eps) override;
1026 1027
1027 // If the alarm was registered, unregister it. 1028 // If the alarm was registered, unregister it.
1028 void UnregisterIfRegistered(); 1029 void UnregisterIfRegistered();
1029 1030
1030 bool registered() const { return registered_; } 1031 bool registered() const { return registered_; }
1031 1032
1032 const EpollServer* eps() const { return eps_; } 1033 const EpollServer* eps() const { return eps_; }
1033 1034
1034 private: 1035 private:
1035 EpollServer::AlarmRegToken token_; 1036 EpollServer::AlarmRegToken token_;
1036 EpollServer* eps_; 1037 EpollServer* eps_;
1037 bool registered_; 1038 bool registered_;
1038 }; 1039 };
1039 1040
1040 } // namespace net 1041 } // namespace net
1041 1042
1042 #endif // NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ 1043 #endif // NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_
OLDNEW
« no previous file with comments | « net/tools/dump_cache/dump_files.cc ('k') | net/tools/epoll_server/epoll_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698