Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace Common {
* @param[in] message string to write
*
*/
void Queue::enqueue_and_log(std::string function, std::string message) {
void Queue::enqueue_and_log(std::string_view function, std::string_view message) {
std::lock_guard<std::mutex> lock(queue_mutex);
message_queue.push(message);
notifier.notify_one();
Expand All @@ -77,9 +77,9 @@ namespace Common {
* @param[in] message string to write
*
*/
void Queue::enqueue_and_log( std::string tag, std::string function, std::string message ) {
void Queue::enqueue_and_log( std::string_view tag, std::string_view function, std::string_view message ) {
std::lock_guard<std::mutex> lock(queue_mutex);
std::stringstream qmessage;
std::ostringstream qmessage;
qmessage << tag << ":" << message;
message_queue.push(qmessage.str());
notifier.notify_one();
Expand All @@ -98,12 +98,12 @@ namespace Common {
* If the queue is empty, wait untill an element is avaiable.
*
*/
std::string Queue::dequeue(void) {
std::string_view Queue::dequeue(void) {
std::unique_lock<std::mutex> lock(queue_mutex);
while(message_queue.empty()) {
notifier.wait(lock); // release lock as long as the wait and reaquire it afterwards.
}
std::string message = message_queue.front();
std::string_view message = message_queue.front();
message_queue.pop();
return message;
}
Expand Down
10 changes: 5 additions & 5 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ namespace Common {
*/
class Queue {
private:
std::queue<std::string> message_queue;
std::queue<std::string_view> message_queue;
mutable std::mutex queue_mutex;
std::condition_variable notifier;
bool is_running;
Expand All @@ -1123,10 +1123,10 @@ namespace Common {
void service_running(bool state) { this->is_running = state; }; ///< set service running
bool service_running() { return this->is_running; }; ///< is the service running?

void enqueue_and_log(std::string function, std::string message);
void enqueue_and_log(std::string tag, std::string function, std::string message);
void enqueue(std::string message); ///< push an element into the queue.
std::string dequeue(void); ///< pop an element from the queue
void enqueue_and_log(std::string_view function, std::string_view message);
void enqueue_and_log(std::string_view tag, std::string_view function, std::string_view message);
void enqueue(std::string message_view); ///< push an element into the queue.
std::string_view dequeue(void); ///< pop an element from the queue
};
/**************** Common::Queue *********************************************/

Expand Down
4 changes: 4 additions & 0 deletions common/sequencerd_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ const std::string SEQUENCERD_GUIDE = "guide";
const std::string SEQUENCERD_MODEXPTIME = "modexptime";
const std::string SEQUENCERD_ONTARGET = "ontarget";
const std::string SEQUENCERD_USERCONTINUE = "usercontinue";
const std::string SEQUENCERD_OP = "op";
const std::string SEQUENCERD_PAUSE = "pause";
const std::string SEQUENCERD_REPEAT = "repeat";
const std::string SEQUENCERD_RESUME = "resume";
const std::string SEQUENCERD_SCRIPT = "script";
const std::string SEQUENCERD_SHUTDOWN = "shutdown";
const std::string SEQUENCERD_START = "start";
const std::string SEQUENCERD_STARTONE = "startone";
Expand Down Expand Up @@ -54,11 +56,13 @@ const std::vector<std::string> SEQUENCERD_SYNTAX = {
SEQUENCERD_GUIDE,
SEQUENCERD_MODEXPTIME+" <exptime>",
SEQUENCERD_ONTARGET,
SEQUENCERD_OP,
SEQUENCERD_PAUSE,
SEQUENCERD_REPEAT,
SEQUENCERD_RESUME,
TELEMREQUEST+" [?]",
SEQUENCERD_USERCONTINUE,
SEQUENCERD_SCRIPT,
SEQUENCERD_SHUTDOWN,
SEQUENCERD_START,
SEQUENCERD_STARTONE,
Expand Down
2 changes: 2 additions & 0 deletions sequencerd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ add_executable(sequencerd
${SEQUENCER_DIR}/sequencer_server.cpp
${SEQUENCER_DIR}/sequencer_interface.cpp
${SEQUENCER_DIR}/sequence_acquisition.cpp
${SEQUENCER_DIR}/sequence_wait.cpp
${SEQUENCER_DIR}/sequence_builder.cpp
${SEQUENCER_DIR}/sequence.cpp
${MYSQL_INCLUDES}
${PYTHON_DEV}
Expand Down
Loading