Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Martiusweb/bim
Browse files Browse the repository at this point in the history
  • Loading branch information
Martiusweb committed Feb 22, 2011
2 parents 61bf9db + 064df60 commit 748fcaf
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.swp
code/server
2 changes: 2 additions & 0 deletions code/prototype/.gitignore
@@ -0,0 +1,2 @@
bin/*
*.o
4 changes: 2 additions & 2 deletions code/prototype/Makefile
Expand Up @@ -10,10 +10,10 @@ all : $(BIN)server
$(OBJ)%.o : $(SRC)%.cpp
$(CXX) $(CPPFLAGS) -c $< -o $@

$(BIN)server : $(OBJ)main.o $(OBJ)server.o
$(BIN)server : $(OBJ)main.o $(OBJ)server.o $(OBJ)dispatcher.o
$(CXX) $(CPPFLAGS) $+ -o $@ -lpthread -D_GNU_SOURCE

main.o : server.hpp
main.o : server.hpp dispatcher.hpp
server.o :

clean :
Expand Down
Binary file modified code/prototype/bin/server
Binary file not shown.
Binary file removed code/prototype/obj/main.o
Binary file not shown.
48 changes: 48 additions & 0 deletions code/prototype/src/dispatcher.cpp
@@ -0,0 +1,48 @@
/**
* This file is part of Bim, the web server which goes fast.
* © Martin Richard & Paul Adenot
*
* Bim is free software : you can redistribute it and/or modify it under the
* terms of the license.
*/


#include "dispatcher.hpp"

#include <unistd.h>
#include <sys/types.h>
#include <sys/epoll.h>

namespace bim
{
dispatcher::dispatcher(int max_events):
_epoll(0), _max_events(max_events)
{
}

dispatcher::~dispatcher()
{
if(_epoll != 0) {
close();
}
}

bool dispatcher::open()
{
if((_epoll = epoll_create(_max_events)) == -1) {
_epoll = 0;
return false;
}
return true;
}

void dispatcher::close()
{
::close(_epoll);
}

void dispatch()
{
}
}

7 changes: 4 additions & 3 deletions code/prototype/src/dispatcher.hpp
Expand Up @@ -6,18 +6,19 @@
* terms of the license.
*/

#include <sys/types.h>

namespace bim {
class dispatcher
{
public:
dispatcher(max_events);
dispatcher(int max_events);
~dispatcher();
bool open();
void close();
void dispatch();

protected:
int _epoll;
int _max_events;
};
}

1 change: 1 addition & 0 deletions code/prototype/src/server.cpp
Expand Up @@ -59,3 +59,4 @@ namespace bim
close();
}
}

0 comments on commit 748fcaf

Please sign in to comment.