Major changes to socket scheduling in EPoll.
This commit is contained in:
1 parent
790906a6dc
commit
a5a51f8aae
512 files changed
+22663
-2121
No files matched your search
+58
@@ -0,0 +1,58 @@
|
||||
#include "INotify.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
INotify::INotify(EPoll &ePoll) : Socket(ePoll, "INotify") {
|
||||
setDescriptor(inotify_init());
|
||||
}
|
||||
|
||||
INotify::~INotify() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
int INotify::addWatch(std::string watch) {
|
||||
return inotify_add_watch(getDescriptor(), watch.c_str(), IN_ALL_EVENTS);
|
||||
}
|
||||
|
||||
void INotify::removeWatch(int wd) {
|
||||
inotify_rm_watch(getDescriptor(), wd);
|
||||
}
|
||||
|
||||
void INotify::onDataReceived(char *buffer, int len) {
|
||||
const struct inotify_event *event;
|
||||
char *ptr;
|
||||
for (ptr = buffer; ptr < buffer + len;
|
||||
ptr += sizeof(struct inotify_event) + event->len) {
|
||||
event = (const struct inotify_event *) ptr;
|
||||
|
||||
if(event->mask & IN_ACCESS)
|
||||
inAccess(std::string(event->name));
|
||||
if(event->mask & IN_ATTRIB)
|
||||
inAttrib(std::string(event->name));
|
||||
if(event->mask & IN_CLOSE_WRITE)
|
||||
inCloseWrite(std::string(event->name));
|
||||
if(event->mask & IN_CLOSE_NOWRITE)
|
||||
inCloseNoWrite(std::string(event->name));
|
||||
if(event->mask & IN_CREATE)
|
||||
inCreate(std::string(event->name));
|
||||
if(event->mask & IN_DELETE)
|
||||
inDelete(std::string(event->name));
|
||||
if(event->mask & IN_DELETE_SELF)
|
||||
inDeleteSelf(std::string(event->name));
|
||||
if(event->mask & IN_MODIFY)
|
||||
inModify(std::string(event->name));
|
||||
if(event->mask & IN_MOVE_SELF)
|
||||
inMoveSelf(std::string(event->name));
|
||||
if(event->mask & IN_MOVED_FROM)
|
||||
inMovedFrom(std::string(event->name));
|
||||
if(event->mask & IN_MOVED_TO)
|
||||
inMovedTo(std::string(event->name));
|
||||
if(event->mask & IN_OPEN)
|
||||
inOpen(std::string(event->name));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user