Skip to content

Commit be40b62

Browse files
committed
Update README.md
1 parent dd2d2c0 commit be40b62

File tree

1 file changed

+4
-160
lines changed

1 file changed

+4
-160
lines changed

README.md

Lines changed: 4 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# SimThreads v2.0.0 Alpha
2-
Parallel Execution for GameMaker 2022.5+
1+
# SimThreads v2.0.1 Beta
2+
Parallel Execution for GameMaker LTS+
33

44
### Quick Disclaimer!
55
This is not "true multithreading". This is merely allowing code to be broken down and spread across several of frames, as oppose to having a massive for loop and manipulating lots of data all within a step.
66

77
If you need any assistance, I'd recommend that you join [My Discord Server, TabularElf's Treehouse](https://discord.gg/ThW5exp6r4) under `💻│gamemaker-libraries`.<br>
8-
Or if you're in [GameMaker Kitchen](https://discord.gg/8krYCqr), check out `your_libraries🧶` for the thread discussion!
8+
Or if you're in [GameMaker Kitchen](https://discord.gg/8krYCqr), check out `other_tubularelf_repos`!
99

1010
Allows multiple execution of functions/methods or block of codes, with arguments provided optionally! This is done by having a handy dandy time_source implementation and custom function to execute functions with arguments (as `script_execute_ext` only works for GML functions and methods, not runtime functions.)
1111
SimThreads has two major kinds of support: Direct calling a method and passing in a function/method with arguments.
@@ -19,160 +19,4 @@ This can be applied to concepts such as:
1919
-Saving/Loading (within reason)<br>
2020
-Anything that could be processed over the course of a couple frames.<br>
2121

22-
Ues case:
23-
24-
`thread = new SimThread([MaxExecutions]);`
25-
26-
By default, SimThreads has a MaxExecution of `infinity` and will process every function/method in its queue until it hits the max thread time (as set by `.SetMaxTime(percent)`, which is default to `100%`, or `1`).
27-
28-
SimThreads can have a function, method or struct passed as a valid argument for both `.Push()` and `.Insert()` (see down below more for the arguments on those functions)
29-
30-
To push a function to a SimThread, you can do.
31-
```gml
32-
thread.Push(myGMLFunction);
33-
```
34-
35-
To push a method to a SimThread, you can do.
36-
```gml
37-
thread.Push(myMethod);
38-
39-
// Or
40-
41-
thread.Push(method(self, myGMLFunction));
42-
43-
// Or
44-
45-
thread.Push(function() {
46-
show_debug_message("Hello World from " + string(self)));
47-
});
48-
```
49-
50-
To push a function/method to a SimThread with arguments, you provide:
51-
52-
```gml
53-
thread.Push({
54-
callback: myGMLFunction,
55-
args: ["Hello World!"]
56-
});
57-
58-
// Or
59-
60-
thread.Push(SimCallback(myGMLFunction, ["Hello World!"]));
61-
```
62-
63-
Giving you the ultimate flexibility in however you want to handle your games logic!
64-
65-
66-
# Example:
67-
```gml
68-
// Create Event
69-
thread = new SimThread();
70-
thread.SetMaxTime(.005);
71-
entriesList = array_create(10000, "the pug is never the end ");
72-
buffer = buffer_create(1, buffer_grow, 1);
73-
// Write a bunch of data to said buffer
74-
var _len = array_length(entriesList);
75-
i = 0;
76-
thread.Loop(_len, function() {
77-
buffer_write(buffer, buffer_text, entriesList[i]);
78-
++i;
79-
}).Finally(function() {
80-
buffer_save(buffer, "mytext.txt");
81-
show_debug_message("Buffer saved!");
82-
buffer_delete(buffer);
83-
});
84-
```
85-
86-
```gml
87-
// Game End Event
88-
thread.Flush();
89-
thread.Destroy();
90-
```
91-
92-
# Methods:
93-
94-
## `.Pause()`
95-
96-
Pauses the SimThread execution.
97-
98-
## `.Resume()`
99-
100-
Resumes the SimThread execution.
101-
102-
## `.SetMaxTime(percent)`
103-
104-
Sets the max time a given SimThread can execute (with `percent` being a value between `0` to `1`) per step.
105-
106-
## `.SetMaxExecution(number)`
107-
108-
Sets the max amount of executions per step. `infinity` is set by default. Any number above `0` will limit the SimThread to that number of function executions.
109-
110-
## `.Loop(size, callback)`
111-
112-
Begins looping a callback until X size is reached. This hooks onto the `.While()` method of `__SimResponseClass`.
113-
114-
Returns: Instance of `__SimResponseClass`.
115-
116-
## `.Insert(position, callback)`
117-
118-
Inserts a function/method or struct to a set position within the SimThread.
119-
120-
Returns: Instance of `__SimResponseClass`.
121-
122-
## `.Push(callback)`
123-
124-
Pushes one or multiple functions/methods or structs, adding at the end of the queue.
125-
126-
Returns: Instance of `__SimResponseClass`.
127-
128-
## `.PushNext(callback)`
129-
130-
Pushes the next callback immediately behind this one.
131-
132-
Returns: Instance of `__SimResponseClass`.
133-
134-
## `.Clear()`
135-
136-
Clears the SimThread queue.
137-
138-
## `.Destroy()`
139-
140-
Frees the SimThread queue.
141-
142-
## `.GetQueueLength()`
143-
144-
Gets the length of the SimThread queue.
145-
146-
## `.Flush()`
147-
148-
Flushes all functions (aka executes all functions/methods) within the queue, regardless of the settings of `.SetMaxTime()` and `.SetMaxExecutions()`, and regardless if it's paused or not.
149-
150-
## `.Break()`
151-
152-
Forces the Simthread to stop whatever code is being executed during the response (in the case of a loop).<br>
153-
Note: This only interrupts the loop, but not the current callback that's still processing. You will need to call `return;` or `exit;` to exit out of the callback.
154-
155-
156-
# `__SimResponseClass` methods.
157-
158-
## `.While(callback)`
159-
160-
Used to indicate whether it should rerun the callback or not, before the callback is executed.
161-
162-
Return: `self`
163-
164-
## `.Until(callback)`
165-
166-
Used to indicate whether it should rerun the callback or not, after the callback is executed.
167-
168-
Return: `self`
169-
170-
## `.Catch(callback)`
171-
172-
Used to handle errors (if any).
173-
174-
## `.Finally(callback)`
175-
176-
Used to fire off an additional callback after the main callback has finished either successfully, has errored out or has called `.Break()`.
177-
178-
Return: `self`
22+
Docs are currently being written.

0 commit comments

Comments
 (0)