diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-05-20 01:08:16 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-05-20 01:08:16 +0200 |
commit | 776377bb21ee1cfe0bcdbc000f7c6fa0be227226 (patch) | |
tree | a60e8bdd92678dece5fbb96e75535eba2b61b7da /src/Common/ActionManager.cpp | |
parent | badc0da3b74d99c90b7b28180d08cd6d08830254 (diff) | |
download | mad-776377bb21ee1cfe0bcdbc000f7c6fa0be227226.tar mad-776377bb21ee1cfe0bcdbc000f7c6fa0be227226.zip |
Netzwerk-Code auf boost::asio umgestellt
Diffstat (limited to 'src/Common/ActionManager.cpp')
-rw-r--r-- | src/Common/ActionManager.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/Common/ActionManager.cpp b/src/Common/ActionManager.cpp deleted file mode 100644 index fc3c034..0000000 --- a/src/Common/ActionManager.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ActionManager.cpp - * - * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "ActionManager.h" -#include <Net/FdManager.h> - -#include <fcntl.h> -#include <signal.h> - -namespace Mad { -namespace Common { - -ActionManager ActionManager::actionManager; - - -void ActionManager::doInit() { - // TODO Error handling - - pipe(notifyPipe); - - fcntl(notifyPipe[0], F_SETFL, fcntl(notifyPipe[0], F_GETFL) | O_NONBLOCK); - fcntl(notifyPipe[1], F_SETFL, fcntl(notifyPipe[1], F_GETFL) | O_NONBLOCK); - - Net::FdManager::get()->registerFd(notifyPipe[0], boost::bind(&ActionManager::run, this), POLLIN); -} - -void ActionManager::doDeinit() { - Net::FdManager::get()->unregisterFd(notifyPipe[0]); - - close(notifyPipe[0]); - close(notifyPipe[1]); -} - - -void ActionManager::run() { - // Empty pipe - char buf[16]; - while(read(notifyPipe[0], buf, sizeof(buf)) > 0) {} - - while(true) { - sigset_t set, oldset; - sigfillset(&set); - sigprocmask(SIG_SETMASK, &set, &oldset); - - if(actions.empty()) { - sigprocmask(SIG_SETMASK, &oldset, 0); - return; - } - - boost::function0<void> action = actions.front(); - actions.pop(); - - sigprocmask(SIG_SETMASK, &oldset, 0); - - action(); - } -} - -void ActionManager::add(const boost::function0<void> &action) { - sigset_t set, oldset; - sigfillset(&set); - sigprocmask(SIG_SETMASK, &set, &oldset); - - actions.push(action); - write(notifyPipe[1], "", 1); - - sigprocmask(SIG_SETMASK, &oldset, 0); -} - -} -} |