diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-03-16 14:21:29 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-03-16 14:21:29 +0000 |
| commit | 113c8fac7f175db8a415c368ceefd62428d45967 (patch) | |
| tree | 84b4f1b4d30f25e31d055397462f4293f316a825 /src/Command.h | |
| parent | 11907c175d9e3e6f4069df79dade320b6f93cd7f (diff) | |
2007-03-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To reduce overhead to find commands whose socket is either
readable or writable in the download engine loop:
* src/Command.h, src/Command.cc
(STATUS): New enum.
(status): New variable.
(statusMatch): New function.
(setStatusActive): New function.
(setStatusInactive): New function.
* src/DownloadEngine.h, src/DownloadEngine.cc
(executeCommand): New function.
(run): Simplified.
(waitData): Call Command::setStatusActive() when command's
socket is
readable or writable.
Diffstat (limited to 'src/Command.h')
| -rw-r--r-- | src/Command.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Command.h b/src/Command.h index e0b9b57e..f9fcb222 100644 --- a/src/Command.h +++ b/src/Command.h @@ -41,14 +41,21 @@ typedef int CommandUuid; class Command { +public: + enum STATUS { + STATUS_ALL, + STATUS_ACTIVE, + STATUS_INACTIVE + }; private: CommandUuid uuid; static int uuidGen; + STATUS status; protected: int cuid; const Logger* logger; public: - Command(int cuid):uuid(uuidGen++), cuid(cuid) { + Command(int cuid):uuid(uuidGen++), status(STATUS_INACTIVE), cuid(cuid) { logger = LogFactory::getInstance(); } virtual ~Command() {} @@ -56,6 +63,12 @@ public: int getCuid() const { return cuid; } const CommandUuid& getUuid() const { return uuid; } + + void setStatusActive() { this->status = STATUS_ACTIVE; } + + void setStatusInactive() { this->status = STATUS_INACTIVE; } + + bool statusMatch(Command::STATUS statusFilter) const; }; #endif // _D_COMMAND_H_ |
