-
Notifications
You must be signed in to change notification settings - Fork 1
/
mtschedman.h
58 lines (50 loc) · 2.16 KB
/
mtschedman.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
#ifndef _MTSCHEDMAN_H_
#define _MTSCHEDMAN_H_ 1
#include<stdint.h>
#include<stddef.h>
#include<mtutil/mtsched.h>
#include<mtutil/rwlock.h>
#include<avlbst/avlbst.h>
//=============================================================================
// mtsched_manager feature: The main purpose of this feature is to manage every
// single job, simplify management of jobs, and let the parallel computing
// more effective.
//-----------------------------------------------------------------------------
typedef struct mtsched_manager_struct
{
rwlock_t l;
mtsched_p s_ref;
uint32_t *joblist;
size_t num_joblist;
size_t max_joblist;
}mtsched_manager_t, *mtsched_manager_p;
//=============================================================================
// Func: mtschedman_create
// Desc: Create a job manager by referencing a mtsched instance.
//-----------------------------------------------------------------------------
mtsched_manager_p mtschedman_create(mtsched_p s);
//=============================================================================
// Func: mtschedman_dispatch
// Desc: Dispatch a job to the scheduler and record the job_id in order to
// monitor the job.
// Params:
// m: The job manager.
// proc: The function entry point.
// Return value:
// Non-zero for success, zero for failure.
//-----------------------------------------------------------------------------
int mtschedman_dispatch(mtsched_manager_p m, mtsched_proc proc, size_t max_args, ...);
//=============================================================================
// Func: mtschedman_finish
// Desc: Wait for all of the jobs that were dispatched by the manager finish.
// Return value:
// Non-zero for success, zero for failure.
//-----------------------------------------------------------------------------
int mtschedman_finish(mtsched_manager_p m);
//=============================================================================
// Func: mtschedman_free
// Desc: Wait for all of the jobs that were dispatched by the manager finish,
// then cleanup memory usage.
//-----------------------------------------------------------------------------
void mtschedman_free(mtsched_manager_p m);
#endif