forked from artyom-beilis/cppcms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.h
More file actions
46 lines (40 loc) · 1.16 KB
/
client.h
File metadata and controls
46 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCMS_TEST_RUN_CLIENT_H
#define CPPCMS_TEST_RUN_CLIENT_H
#include <stdlib.h>
#include <string>
#include <cppcms/service.h>
#include <cppcms/thread_pool.h>
#include <cppcms/json.h>
static bool run_ok=false;
struct runner {
runner(cppcms::service &srv) : srv_(&srv)
{
command_ = srv.settings().get<std::string>("test.exec","none");
}
void operator()() const
{
if(command_ != "none") {
run_ok = ::system(command_.c_str()) == 0;
srv_->shutdown();
}
}
private:
cppcms::service *srv_;
std::string command_;
};
struct submitter {
submitter(cppcms::service &srv) : srv_(&srv) {}
void operator()() const
{
srv_->thread_pool().post(runner(*srv_));
}
cppcms::service *srv_;
};
#endif