1 | /* |
---|
2 | This is part of the OTF library. Copyright by ZIH, TU Dresden 2005-2008. |
---|
3 | Authors: Andreas Knuepfer, Holger Brunst, Ronny Brendel, Thomas Kriebitzsch |
---|
4 | */ |
---|
5 | |
---|
6 | /** |
---|
7 | * @file OTF_FileManager.h |
---|
8 | * |
---|
9 | * @brief Manages file handles. |
---|
10 | * |
---|
11 | * i.e. Opens, closes and suspends files, if there are not enough |
---|
12 | * filehandles available. |
---|
13 | * |
---|
14 | * \ingroup fm |
---|
15 | */ |
---|
16 | |
---|
17 | /** |
---|
18 | * \defgroup fm File Manager Interface |
---|
19 | * |
---|
20 | * The file manager schedules an unlimited number OTF_Files to a limited |
---|
21 | * number of actual open OS files. Therefore all open are registered with |
---|
22 | * this manager. When a file is requested while no more OS files are |
---|
23 | * available any of the other files are suspended, i.i. the OS file is |
---|
24 | * closed. |
---|
25 | */ |
---|
26 | |
---|
27 | |
---|
28 | #ifndef OTF_FILEMANAGER_H |
---|
29 | #define OTF_FILEMANAGER_H |
---|
30 | |
---|
31 | |
---|
32 | #include "OTF_inttypes.h" |
---|
33 | |
---|
34 | |
---|
35 | #ifdef __cplusplus |
---|
36 | extern "C" { |
---|
37 | #endif /* __cplusplus */ |
---|
38 | |
---|
39 | struct struct_OTF_File; |
---|
40 | typedef struct struct_OTF_File OTF_File; |
---|
41 | |
---|
42 | |
---|
43 | struct struct_OTF_FileManager; |
---|
44 | /** file manager object \ingroup fm */ |
---|
45 | typedef struct struct_OTF_FileManager OTF_FileManager; |
---|
46 | |
---|
47 | |
---|
48 | /** Generates a new file manager with a maximum number of files that are allowed |
---|
49 | to be open simultaneously. \ingroup fm */ |
---|
50 | OTF_FileManager* OTF_FileManager_open( uint32_t number ); |
---|
51 | |
---|
52 | /** Closes the file manager \ingroup fm */ |
---|
53 | void OTF_FileManager_close( OTF_FileManager* m ); |
---|
54 | |
---|
55 | /** Returns the number of files currently open. */ |
---|
56 | uint32_t OTF_FileManager_getCount( OTF_FileManager* m ); |
---|
57 | |
---|
58 | /** Returns the numbner of files allowed to be open simultaneously. */ |
---|
59 | uint32_t OTF_FileManager_getNumber( OTF_FileManager* m ); |
---|
60 | |
---|
61 | /** Sets the number of files allowed to be open simultaneously. */ |
---|
62 | uint32_t OTF_FileManager_setNumber( OTF_FileManager* m, uint32_t number ); |
---|
63 | |
---|
64 | /** Ensure there is a free file handle available after this call. |
---|
65 | return 1 on success, 0 otherwise (which is not supposed to happen) */ |
---|
66 | int OTF_FileManager_guaranteeFile( OTF_FileManager* m ); |
---|
67 | |
---|
68 | /** Registers the 'file' as open. Return 1 on success, 0 otherwise. */ |
---|
69 | int OTF_FileManager_registerFile( OTF_FileManager* m, OTF_File* file ); |
---|
70 | |
---|
71 | /** Marks currently opened 'file' as used which is important for the |
---|
72 | scheduling strategy, i.e. the internal decision which file to suspend next. |
---|
73 | return 1 on success or 0 for an suspended file. */ |
---|
74 | int OTF_FileManager_touchFile( OTF_FileManager* m, OTF_File* file ); |
---|
75 | |
---|
76 | /** Suspend an open file explicitly. this may be called externaly or |
---|
77 | internally. Return 1 on success, 0 otherwise. */ |
---|
78 | int OTF_FileManager_suspendFile( OTF_FileManager* m, OTF_File* file ); |
---|
79 | |
---|
80 | #ifdef __cplusplus |
---|
81 | } |
---|
82 | #endif /* __cplusplus */ |
---|
83 | |
---|
84 | #endif /* OTF_FILEMANAGER_H */ |
---|
85 | |
---|