2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Nicklas P Andersson
22 #include "../StdAfx.h"
24 #include "AMCPCommandQueue.h"
26 #include <boost/timer.hpp>
28 namespace caspar { namespace protocol { namespace amcp {
30 AMCPCommandQueue::AMCPCommandQueue()
31 : executor_(L"AMCPCommandQueue")
35 AMCPCommandQueue::~AMCPCommandQueue()
39 void AMCPCommandQueue::AddCommand(AMCPCommand::ptr_type pCurrentCommand)
44 if(executor_.size() > 128)
48 CASPAR_LOG(error) << "AMCP Command Queue Overflow.";
49 CASPAR_LOG(error) << "Failed to execute command:" << pCurrentCommand->print();
50 pCurrentCommand->SetReplyString(L"500 FAILED\r\n");
51 pCurrentCommand->SendReply();
55 CASPAR_LOG_CURRENT_EXCEPTION();
59 executor_.begin_invoke([=]
66 if(pCurrentCommand->Execute())
67 CASPAR_LOG(debug) << "Executed command: " << pCurrentCommand->print() << " " << timer.elapsed();
69 CASPAR_LOG(warning) << "Failed to execute command: " << pCurrentCommand->print() << " " << timer.elapsed();
73 CASPAR_LOG_CURRENT_EXCEPTION();
74 CASPAR_LOG(error) << "Failed to execute command:" << pCurrentCommand->print();
75 pCurrentCommand->SetReplyString(L"500 FAILED\r\n");
78 pCurrentCommand->SendReply();
80 CASPAR_LOG(trace) << "Ready for a new command";
84 CASPAR_LOG_CURRENT_EXCEPTION();