-
Notifications
You must be signed in to change notification settings - Fork 3
/
ultra_machine_internals.h
113 lines (87 loc) · 2.08 KB
/
ultra_machine_internals.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* This file is a part of the source code of "byenow" program.
*
* Copyright (c) 2020- Alexander Pankratov and IO Bureau SA.
* All rights reserved.
*
* The source code is distributed under the terms of 2-clause
* BSD license with the Commons Clause condition. See LICENSE
* file for details.
*/
#ifndef _ULTRA_MACHINE_INTERNAL_H_
#define _ULTRA_MACHINE_INTERNAL_H_
#include "ultra_machine.h"
#include "libp/_simple_work_queue.h"
//
struct ultra_mach;
//
struct ultra_task : work_item, fsi_scan_cb, api_error_cb
{
ultra_task(ultra_mach * mach);
__no_copying(ultra_task);
/*
* work_item
*/
void execute();
void do_delete_file(const fsi_item & f);
void do_delete_self();
/*
* fsi_scan_cb
*/
void on_fsi_open(HANDLE h) { }
bool on_fsi_scan(const wc_range & name, const fsi_info & info);
/*
* api_error_cb
*/
void on_api_error_x(const api_error & e);
//
ultra_mach * mach;
folder * curr;
int phase;
size_t ph2_first; // delete curr->files[first, first+count-1]
size_t ph2_count;
wstring path;
api_error_vec errors;
};
typedef vector<ultra_task *> ultra_task_vec;
//
struct ultra_task_pool
{
ultra_task_pool();
~ultra_task_pool();
__no_copying(ultra_task_pool);
//
ultra_task * get(folder * d, int phase);
void put(ultra_task * w);
bool unused() const;
ultra_mach * mach;
ultra_task_vec cache;
size_t allocated;
};
//
struct ultra_mach
{
ultra_mach_conf conf;
ultra_mach_cb * cb;
bool ph1_only; // aka 'just_scan'
simple_work_queue swq;
ultra_task_pool pool;
bool enough;
ultra_mach_info info;
size_t ph1_work, ph2_work, ph3_work;
size_t ph1_done, ph2_done, ph3_done;
//
ultra_mach();
~ultra_mach();
bool init(const ultra_mach_conf & conf, ultra_mach_cb * cb);
void term();
bool keep_going() const;
void enqueue_ph1(folder * x);
void enqueue_ph2(folder * x);
void enqueue_ph3(folder * x);
void complete_ph1(ultra_task * w);
void complete_ph2(ultra_task * w);
void complete_ph3(ultra_task * w);
void loop();
};
#endif