Skip to content

Commit

Permalink
perf hot func
Browse files Browse the repository at this point in the history
  • Loading branch information
songbingyu committed Nov 5, 2014
1 parent 0d5ffbd commit c287ed6
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/ActiveEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ActiveFdEvent
void addList( EventIo* ev );
void delList( EventIo* ev );
tiny_forceinline void tiny_cold killFd( EventLoop* loop );
tiny_forceinline void fdEvent( EventLoop* loop, int revents );
tiny_hot tiny_forceinline void fdEvent( EventLoop* loop, int revents );
public:
EventIo* head_;
int events_;
Expand Down
6 changes: 3 additions & 3 deletions src/Connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ void Connection::onEvents( EventLoop* loop, IEvent* ev, int revents )
{
Connection* conn = (Connection*)ev->getUserData();
if( NULL != conn ){
if( revents&EV_READ ){
if( expect_true(revents&EV_READ) ){

conn->onRead();

}else if( revents&EV_WRITE ){
}else if( expect_false(revents&EV_WRITE) ){

conn->onWrite();

}else if( revents&EV_ERROR ){
}else if( expect_false(revents&EV_ERROR) ){

conn->onError();
}else {
Expand Down
11 changes: 6 additions & 5 deletions src/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ class Connection : public IConnection
Connection( int fd, EventLoop* loop, struct sockaddr_in& addr );
~Connection();
public:
int onRead ();
int onWrite();
int onClose();
int onError();
tiny_hot tiny_forceinline int onRead ();
tiny_forceinline int onWrite();
tiny_forceinline int onClose();
tiny_forceinline int onError();

int onConnFinish();
int onConnDestory();
public:
void send( char* data, int len );
void close();
void setTcpNoDelay() { socketHelper_->setTcpNoDelay( sockfd_,false ); }
public:
static void onEvents( EventLoop* loop, IEvent* ev, int revents );
tiny_hot tiny_forceinline static void onEvents( EventLoop* loop, IEvent* ev, int revents );

public:

Expand Down
2 changes: 1 addition & 1 deletion src/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class IEvent
data_ = NULL;
}
public:
void onEvent(int revents );
tiny_hot void onEvent(int revents );
tiny_forceinline void ev_start( int active );
tiny_forceinline void ev_stop();
tiny_forceinline bool isActive() const { return active_ > 0 ; }
Expand Down
2 changes: 1 addition & 1 deletion src/EventEpoll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#define EV_EPERM 0x80

EventEpoll::EventEpoll( EventLoop* loop ): IPoller( loop ), epollfd_( -1 ),epollEventMax_(64),events_( epollEventMax_ )
EventEpoll::EventEpoll( EventLoop* loop ): IPoller( loop ), epollfd_( -1 ),epollEventMax_(128),events_( epollEventMax_ )
{
epollCreate() ;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EventLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public :
public:
int run( int flags );
public:
void addPendingEvent( IEvent* ev, int evFlag );
tiny_hot tiny_forceinline void addPendingEvent( IEvent* ev, int evFlag );
void delPendingEvent(IEvent* ev );
void addActiveFdEvent ( EventIo* ev );
void delActiveFdEvent ( EventIo* ev );
Expand All @@ -49,7 +49,7 @@ public :
void onSignalEvent();
void addFeedReverse( IEvent* ev );
void feedReverseDone( int revents );
ActiveFdEvent* getActiveFdEventByFd( int fd );
tiny_hot tiny_forceinline ActiveFdEvent* getActiveFdEventByFd( int fd );
tiny_forceinline void addActiveCnt() { ++activeCnt_; }
tiny_forceinline void delActiveCnt() { --activeCnt_; }
tiny_forceinline Timestamp getNowTime() const { return curTime_; }
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SimpleBuffer

bool hasWritten( size_t len )
{
tiny_assert( len < (size_t)freeSize() );
tiny_assert( len <= (size_t)freeSize() );
end_ += len;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SocketHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class SocketHelper
static int accept( int fd,struct sockaddr_in* addr );
static int connect(int fd, const struct sockaddr_in* addr );
int read( int fd, char* buf, int len );
int write( int fd, char* buf, int len );
tiny_hot int write( int fd, char* buf, int len );
//TODO readv writev
int readv(int fd, const struct iovec* iov, int iovcnt );
tiny_hot int readv(int fd, const struct iovec* iov, int iovcnt );

int close( int fd );
static int shutdown( int fd );
Expand Down

0 comments on commit c287ed6

Please sign in to comment.