GoWebScan API
GoWebScanPipe.h
Go to the documentation of this file.
1 /**
2 * @file GoWebScanPipe.h
3 * @brief Declares a GoWebScanPipe object.
4 *
5 * @internal
6 * Copyright (C) 2017-2026 by LMI Technologies Inc.
7 * Licensed under the MIT License.
8 * Redistributed files must retain the above copyright notice.
9 */
10 #ifndef GO_WEB_SCAN_PIPE_H
11 #define GO_WEB_SCAN_PIPE_H
12 
16 
17 /**
18 * @class GoWebScanPipe
19 * @extends kObject
20 * @ingroup GoWebScanSdk-Pipe
21 * @brief Represents a pipeline to run sequences of processing tasks concurrently. A GoWebScanPipe object
22 * coordinates executing GoWebScanPipeTask objects that have received a GoWebScanPipeMsg, and coordinates
23 * passing messages from task to task as processing steps execute. The pipe maintains a a priority
24 * queue of processing jobs, ordered by stage, and a thread pool to execute jobs. Higher priority
25 * jobs (higher stage number) are dispatched for processing before lower priority jobs.
26 */
27 typedef kObject GoWebScanPipe;
28 
29 // Forward declaration
31 
32 /** Defines the signature of the handler used by tasks to receive a message from the pipe. */
33 typedef kStatus(kCall *GoWebScanPipeSendFx)(kPointer context, GoWebScanPipeMsg msg);
34 
35 /**
36 * Constructs a GoWebScanPipe object.
37 *
38 * @public @memberof GoWebScanPipe
39 * @param pipe Receives the constructed GoWebScanPipe object.
40 * @param allocator Memory allocator (or kNULL for default).
41 * @return Operation status.
42 */
43 GoWebScanFx(kStatus) GoWebScanPipe_Construct(GoWebScanPipe* pipe, kAlloc allocator);
44 
45 /**
46 * Sets the number of threads to be used by the pipe. If not set, the thread count will
47 * default to the maximum number of processors available in the host.
48 *
49 * @public @memberof GoWebScanPipe
50 * @param pipe GoWebScanPipe object.
51 * @param count Thread count.
52 * @return Operation status.
53 */
55 
56 /**
57 * Gets the number of threads to be used by the pipe
58 *
59 * @public @memberof GoWebScanPipe
60 * @param pipe GoWebScanPipe object.
61 * @return Thread count.
62 */
64 
65 /**
66 * Adds a task to the pipe.
67 *
68 * @public @memberof GoWebScanPipe
69 * @param pipe GoWebScanPipe object.
70 * @param task Pointer to task to add.
71 * @return Operation status.
72 */
74 
75 /**
76 * Adds a message pool to the pipe.
77 *
78 * @public @memberof GoWebScanPipe
79 * @param pipe GoWebScanPipe object.
80 * @param pool Pointer to pool to add.
81 * @return Operation status.
82 */
84 
85 /**
86 * Initializes the pipe. Must be called after the thread count has been set and tasks have been added to the pipe.
87 *
88 * @public @memberof GoWebScanPipe
89 * @param pipe GoWebScanPipe object.
90 * @return Operation status.
91 */
92 GoWebScanFx(kStatus) GoWebScanPipe_Start(GoWebScanPipe pipe);
93 
94 /**
95 * Receives and frees all messages exiting the pipe until the pipe is empty.
96 *
97 * @public @memberof GoWebScanPipe
98 * @param pipe GoWebScanPipe object.
99 * @return Operation status.
100 */
101 GoWebScanFx(kStatus) GoWebScanPipe_Clear(GoWebScanPipe pipe);
102 
103 /**
104 * Dispatches a processing job (task + message) to the pipe. Sends the message to a task's message queue.
105 * The task will submit the message to the pipe for processing if no other job is pending.
106 *
107 * @public @memberof GoWebScanPipe
108 * @param pipe GoWebScanPipe object.
109 * @param task Task to receive message.
110 * @param msg Message to enqueue for processing.
111 * @return Operation status.
112 */
114 
115 /**
116 * Receives a completed processing job from the pipe. Retrieves the first out message from the outgoing queue
117 * and increases the reference count of this message.
118 *
119 * @public @memberof GoWebScanPipe
120 * @param pipe GoWebScanPipe object.
121 * @param msg Receives processed GoWebScanPipeMsg object.
122 * @param timeout Timeout for waiting to receive a message (in microseconds). kINFINITE to wait indefinitely.
123 * @return Operation status.
124 */
125 GoWebScanFx(kStatus) GoWebScanPipe_Receive(GoWebScanPipe pipe, GoWebScanPipeMsg* msg, k64u timeout);
126 
127 /**
128 * Adds a completed message to the pipe's outgoing queue. Only used by GoWebScanPipeTask once processing is completed
129 * on a message.
130 *
131 * @public @memberof GoWebScanPipe
132 * @param pipe GoWebScanPipe object.
133 * @param msg Completed message.
134 * @return Operation status.
135 */
137 
138 /**
139 * Gets the current count of processing errors that have occurred in the pipe
140 *
141 * @public @memberof GoWebScanPipe
142 * @param pipe GoWebScanPipe object.
143 * @return Error count.
144 */
145 GoWebScanFx(kSize) GoWebScanPipe_ErrorCount(GoWebScanPipe pipe);
146 
147 #include <GoWebScanSdk/GoWebScanPipe.x.h>
148 
149 #endif
150 
kStatus(kCall * GoWebScanPipeSendFx)(kPointer context, GoWebScanPipeMsg msg)
Defines the signature of the handler used by tasks to receive a message from the pipe.
Definition: GoWebScanPipe.h:33
kStatus GoWebScanPipe_AddMsgPool(GoWebScanPipe pipe, GoWebScanPipeMsgPool *pool)
Adds a message pool to the pipe.
kSize GoWebScanPipe_ThreadCount(GoWebScanPipe pipe)
Gets the number of threads to be used by the pipe.
kStatus GoWebScanPipe_AddTask(GoWebScanPipe pipe, GoWebScanPipeTask *task)
Adds a task to the pipe.
kStatus GoWebScanPipe_Emit(GoWebScanPipe pipe, GoWebScanPipeMsg msg)
Adds a completed message to the pipe's outgoing queue.
Declares the GoWebScanPipeMsg class.
Declares the GoWebScanPipeMsgPool class.
kStatus GoWebScanPipe_SetThreadCount(GoWebScanPipe pipe, kSize count)
Sets the number of threads to be used by the pipe.
kStatus GoWebScanPipe_Dispatch(GoWebScanPipe pipe, GoWebScanPipeTask task, GoWebScanPipeMsg msg)
Dispatches a processing job (task + message) to the pipe.
Essential GoWebScan declarations.
kStatus GoWebScanPipe_Construct(GoWebScanPipe *pipe, kAlloc allocator)
Constructs a GoWebScanPipe object.
kStatus GoWebScanPipe_Clear(GoWebScanPipe pipe)
Receives and frees all messages exiting the pipe until the pipe is empty.
Represents a processing task for the GoWebScanPipe class. Each GoWebScanPipeTask maintains a FIFO que...
kStatus GoWebScanPipe_Receive(GoWebScanPipe pipe, GoWebScanPipeMsg *msg, k64u timeout)
Receives a completed processing job from the pipe.
Represents a pipeline to run sequences of processing tasks concurrently. A GoWebScanPipe object coord...
Represents a pool of GoWebScanPipeMsg objects. The pool allocates GoWebScanPipeMsg objects with a def...
Base class for a msg that can be processed with a GoWebScanPipeTask and submitted to the GoWebScanPip...
kStatus GoWebScanPipe_Start(GoWebScanPipe pipe)
Initializes the pipe.
kSize GoWebScanPipe_ErrorCount(GoWebScanPipe pipe)
Gets the current count of processing errors that have occurred in the pipe.