Skip to content

Commit ecb8300

Browse files
Adding comments to the source code.
1 parent c8fbd75 commit ecb8300

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

neural/neuralthread.pas

+50-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
1-
// Neural Threads
1+
(*
2+
Neural Threads
3+
Copyright (C) 2021 Joao Paulo Schwarz Schuler
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 2 of the License, or
8+
any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License along
16+
with this program; if not, write to the Free Software Foundation, Inc.,
17+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*)
19+
(*
20+
USAGE:
21+
This API has easy to use, lightweight and platform independent parallel
22+
processing API methods.
23+
24+
As an example, assuming that you need to run a procedure 10 times in parallel,
25+
you can create 10 thread workers as follows:
26+
FProcs := TNeuralThreadList.Create( 10 );
27+
28+
As an example, this is the procedure that we intend to run in parallel:
29+
procedure MyClassName.RunNNThread(index, threadnum: integer);
30+
begin
31+
WriteLn('This is thread ',index,' out of ',threadnum,' threads.');
32+
end;
33+
34+
Then, to run the procedure RunNNThread passed as parameter 10 times in parallel, do this:
35+
FProcs.StartProc({$IFDEF FPC}@RunNNThread{$ELSE}RunNNThread{$ENDIF});
36+
37+
You can control the blocking mode (waiting threads to finish
38+
before the program continues) as per declaration:
39+
procedure StartProc(pProc: TNeuralProc; pBlock: boolean = true);
40+
41+
Or, if you prefer, you can specifically say when to wait for threads to finish
42+
as per this example:
43+
FProcs.StartProc({$IFDEF FPC}@RunNNThread{$ELSE}RunNNThread{$ENDIF}, false);
44+
// insert your code here
45+
FProcs.WaitForProc(); // waits until all threads are finished.
46+
47+
When you are done, you should call:
48+
FProcs.Free;
49+
*)
50+
251
unit neuralthread;
352
{$include neuralnetwork.inc}
453

0 commit comments

Comments
 (0)