From b14e4cd9c5d7cf732ec74f52288cc6fa34e7cd6d Mon Sep 17 00:00:00 2001 From: "daiyoung777.kim" Date: Mon, 26 Nov 2012 13:10:39 +0900 Subject: [PATCH] modify linux build, - add task class --- vts/ext/luabridge-0.2/lib/libluabridge.a | Bin 11592 -> 11592 bytes vts/src/Makefile | 15 +++++++------ vts/src/netutil.cpp | 4 ++++ vts/src/task.cpp | 29 +++++++++++++++++++++++++ vts/src/task.h | 36 +++++++++++++++++++++++++++++++ vts/src/util.cpp | 4 ++-- 6 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 vts/src/task.cpp create mode 100644 vts/src/task.h diff --git a/vts/ext/luabridge-0.2/lib/libluabridge.a b/vts/ext/luabridge-0.2/lib/libluabridge.a index b63829d422fbd018cb556de9c983cc228591cdb6..e2a149098f11e70c1a44def183418e9f2be533d1 100644 GIT binary patch delta 44 mcmX>Rbs}nlG`q2xiJ6(PRbs}nlG`o?xfuW&+;YOvIOfdH5Lrgct;G9L0%Y*?g^$ipN diff --git a/vts/src/Makefile b/vts/src/Makefile index 194afa7..1906a9e 100644 --- a/vts/src/Makefile +++ b/vts/src/Makefile @@ -5,10 +5,10 @@ LUAFLAGS = -L../ext/luabridge/lib/ -I../src/ UNAME := $(shell uname) -ifeq ($(UNAME), Linux) -PALTFORMSTR = linux +ifeq ($(UNAME),Linux) +PLATFORMSTR = linux CFLAGS += -ldl -pthread -LUAFLAGS += LUALIB +LUAFLAGS += $(LUALIB) else PLATFORMSTR = win32 CFLAGS += -pthread -lwsock32 -L-Ladvapi32 -L/mingw/lib @@ -36,27 +36,30 @@ buildinfo : @echo $(LUAFLAGS) ifeq ($(UNAME), Linux) -emtest : $(OBJECTS) +emtest : $(OBJECTS_WIN) @echo "start emtest build for linux.." - $(CC) -o $(BINDIR)$@ $^ $(CFLAGS) $(LUAFLAGS) + $(CC) -o $(BINDIR)$@ $^ $(LUAFLAGS) $(CFLAGS) && $(CC) -o $(BINDIR)actshell actshell.cpp $(CFLAGS) && cp $(BINDIR)* ../bin #endif #ifeq ($(UNAME), MINGW32) else emtest : $(OBJECTS_WIN) @echo "start emtest build for windows.." @echo $(OBJECTS_WIN) - $(CC) -o $(BINDIR)$@ $^ $(CFLAGS) $(LUAFLAGS) + $(CC) -o $(BINDIR)$@ $^ $(CFLAGS) $(LUAFLAGS) && cp $(BINDIR)* ../bin endif ifeq ($(UNAME), mac) emtest : $(OBJECTS) @echo "start emtest build for mac.. do somethig.." endif +preparetest : + cp $(BINDIR)* ../bin clean : rm -rf *.o rm -rf $(OUTDIR)*.o rm -rf $(BINDIR)emtest + rm -rf $(BINDIR)actshell install : mkdir -p ../out diff --git a/vts/src/netutil.cpp b/vts/src/netutil.cpp index 5ecce2f..9124ac0 100644 --- a/vts/src/netutil.cpp +++ b/vts/src/netutil.cpp @@ -63,7 +63,11 @@ sock::~sock() void sock::close_s() { +#ifdef WIN32 closesocket(m_s); +#else + close(m_s); +#endif } bool sock::create() diff --git a/vts/src/task.cpp b/vts/src/task.cpp new file mode 100644 index 0000000..b5fc328 --- /dev/null +++ b/vts/src/task.cpp @@ -0,0 +1,29 @@ + +#include "task.h" + +namespace slib { + +// +// TaskQueue +// +bool TaskQueue::Queue(ITask* task) +{ + m_tq.push((Task*)task); + return true; +} + +void TaskQueue::Dispatch() +{ + while (!m_tq.empty()) + { + Task* task = m_tq.front(); + m_tq.pop(); + + { + task->work(); + } + } +} + + +} // end of namespace diff --git a/vts/src/task.h b/vts/src/task.h new file mode 100644 index 0000000..4fffbfc --- /dev/null +++ b/vts/src/task.h @@ -0,0 +1,36 @@ +#ifndef __task_h__ +#define __task_h__ + +#include + + +namespace slib { + +struct ITask +{ + virtual void work() = 0; +}; + + +class Task : public ITask +{ +public: + virtual void work(){} +}; + + +class TaskQueue +{ +public: + virtual bool Queue(ITask* task); + virtual void Dispatch(); +private: + typedef std::queue TaskQueueT; + TaskQueueT m_tq; +}; + + + } // end of namespace + + +#endif diff --git a/vts/src/util.cpp b/vts/src/util.cpp index 2cd2deb..1b1c4a4 100644 --- a/vts/src/util.cpp +++ b/vts/src/util.cpp @@ -60,7 +60,7 @@ void ssleep(int seconds) #ifdef WIN32 Sleep(seconds * 1000); #else - seconds(sleepMs * 1000); + sleep(seconds); #endif -} \ No newline at end of file +} -- 2.7.4