HepLib
Loading...
Searching...
No Matches
BASIC
PoolPipe.h
Go to the documentation of this file.
1
6
#pragma once
7
8
#include <vector>
9
#include <memory>
10
#include <mutex>
11
#include <condition_variable>
12
#include <functional>
13
#include <sys/wait.h>
14
#include <sys/stat.h>
15
16
namespace
HepLib
{
17
18
class
Pool
{
19
public
:
20
explicit
Pool
(
const
std::vector<void*> & vec);
21
void
*
acquire
();
22
void
release
(
void
* obj);
23
private
:
24
std::vector<void*> ava;
25
std::mutex mtx;
26
std::condition_variable cv;
27
};
28
29
class
Pipe
{
30
public
:
31
explicit
Pipe
(
const
std::function<std::string(
const
std::string &)> & fi);
32
~Pipe
();
33
std::string
run
(
const
std::string &code);
34
private
:
35
int
p2c[2], c2p[2];
36
pid_t pid;
37
std::function<std::string(
const
std::string &)> f;
38
};
39
40
class
PipePool
{
41
public
:
42
explicit
PipePool
(
int
size,
const
std::function<std::string(
const
std::string &)> & f);
43
std::string
run
(
const
std::string & code);
44
std::vector<std::string>
run_all
(
const
std::string &code);
45
~PipePool
();
46
private
:
47
Pool
* pool;
48
std::vector<Pipe*> pipe_ptr_vec;
49
};
50
51
52
}
HepLib::PipePool
Definition
PoolPipe.h:40
HepLib::PipePool::run
std::string run(const std::string &code)
Definition
PoolPipe.cpp:118
HepLib::PipePool::run_all
std::vector< std::string > run_all(const std::string &code)
Definition
PoolPipe.cpp:125
HepLib::PipePool::~PipePool
~PipePool()
Definition
PoolPipe.cpp:113
HepLib::Pipe
Definition
PoolPipe.h:29
HepLib::Pipe::run
std::string run(const std::string &code)
Definition
PoolPipe.cpp:86
HepLib::Pipe::~Pipe
~Pipe()
Definition
PoolPipe.cpp:80
HepLib::Pool
Definition
PoolPipe.h:18
HepLib::Pool::acquire
void * acquire()
Definition
PoolPipe.cpp:18
HepLib::Pool::release
void release(void *obj)
Definition
PoolPipe.cpp:26
HepLib
HepLib namespace.
Definition
BASIC.cpp:17
Generated by
1.9.8