Skip to content

Commit aafcc90

Browse files
committed
Various improvements [v.1.1.0]
Add examples.
1 parent 742147e commit aafcc90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1257
-124
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# PThreading
2-
PThreading: A simple multithreaded framework for Processing.
2+
PThreading: A framework for multithreaded drawing in [Processing](https://processing.org/).
33

44
---
55

6-
The framework consists of two classes: `PThread` and `PThreadManager`. Override the `PThread` class with your code and then add instances of your new class to a PThreadManager to run the instances as threads that draw into your Processing sketch in a multithreaded manner.
6+
The framework consists of two classes: `PThread` and `PThreadManager`. Override the `PThread` class with Processing code and then add instances of your new class to a PThreadManager; this will run the instances as threads that draw into your Processing sketch in a multithreaded manner.
77

88
## Motivation
99

@@ -15,7 +15,7 @@ Processing does indeed provide a quick and dirty way to implement a simple threa
1515
1616
... leaving *thread()* suitable only for CPU-bound sketches, at best.
1717

18-
In contrast, PThreading provides a way to do multithreaded drawing -- not just calculation -- and does so in an easy-to-use and well-synchronized manner. It exploits the fact that PGraphics objects can be drawn into safely from other threads.
18+
In contrast, PThreading provides a way to do **multithreaded drawing** -- not just calculation -- and does so in an easy-to-use and well-synchronized manner. It exploits the fact that *PGraphics* objects can be drawn into safely from other threads.
1919

2020
## Setup
2121

@@ -34,7 +34,7 @@ Download *pthreading.jar* from [releases](https://github.com/micycle1/PThreading
3434

3535
### 1. Extending PThread
3636

37-
Create a new class that extends PThread. You have to override the PThread's *draw()* method; overriding *calc()* is optional. In *draw()*, put Processing drawing code that you wish to be executed as a thread. A very simple example is shown below:
37+
Create a new class that extends PThread. You have to override the PThread's *draw()* method; overriding *calc()* and *setup()* is optional. In *draw()*, put Processing drawing code that you wish to be executed as a thread. A very simple example is shown below:
3838

3939
#### PDE Example:
4040

@@ -77,8 +77,9 @@ class myThread extends PThread {
7777
```
7878

7979
**Important**:
80-
* Prefix every call to a Processing draw method with g -- for example: *g.rect(10,10,10,10)* (relevant in all environments).
81-
* Prefix every call to a Processing variable with p -- for example: *p.mousePressed* (relevant in non-PDE environments only).
80+
* Prefix every call to a Processing **draw method** with **g** -- for example: *g.rect(10,10,10,10)* (relevant in all environments).
81+
* Prefix every call to a Processing **variable** with **p** -- for example: *p.mousePressed* (relevant in non-PDE environments only).
82+
* By default, *smooth()* is enabled for threads. Put *g.noSmooth();* in the thread consructor to disable anti-aliasing and thereby improve draw FPS.
8283

8384
### 2. Creating a PThreadManager
8485
Create a thread manager and add threads to it. A [variety](micycle1.github.io/PThreading/pthreading/PThreadManager.html) of constructors are available. In this example the most simple constructor has been chosen. You can add multiple types of threads to a single thread manager.
@@ -104,8 +105,7 @@ Alternatively, you can call `threadManager.bindDraw()` once -- in `setup` for ex
104105

105106
---
106107

107-
That's it: now `a` and `b` will run as threads, drawing into the sketch. See /examples for more sophisticated behaviour.
108+
That's it: now `a` and `b` will run as threads, drawing into the sketch. See the repo [examples](https://github.com/micycle1/PThreading/tree/master/examples) for the framework in action and more sophisticated behaviour.
108109

109110
## Limitations
110111
Each thread uses the `Java2D` renderer, since this is the only renderer that allows PGraphics objects to be instantiated and drawn into from other threads. As a consequence you cannot **thread** `OPENGL` drawing, or any 3D draw functions -- note that you can still use the framework with a 3D sketch but any drawing with the PThreads is limited to 2D.
111-
Not all sketches are suitable:

docs/allclasses-index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>All Classes</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="script.js"></script>

docs/allpackages-index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>All Packages</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="script.js"></script>

docs/constant-values.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>Constant Field Values</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="script.js"></script>

docs/deprecated-list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>Deprecated List</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="script.js"></script>

docs/help-doc.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>API Help</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="script.js"></script>

docs/index-files/index-1.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>A-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-10.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>S-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>
@@ -81,6 +81,10 @@
8181
</a>
8282
<h2 class="title">S</h2>
8383
<dl>
84+
<dt><span class="memberNameLink"><a href="../pthreading/PThread.html#setup()">setup()</a></span> - Method in class pthreading.<a href="../pthreading/PThread.html" title="class in pthreading">PThread</a></dt>
85+
<dd>
86+
<div class="block">An optional override.</div>
87+
</dd>
8488
<dt><span class="memberNameLink"><a href="../pthreading/PThreadManager.html#stopThread(pthreading.PThread...)">stopThread(PThread...)</a></span> - Method in class pthreading.<a href="../pthreading/PThreadManager.html" title="class in pthreading">PThreadManager</a></dt>
8589
<dd>
8690
<div class="block">Stops a given thread or threads (varargs) and removes it from the thread

docs/index-files/index-11.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>U-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-2.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>B-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-3.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>C-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>
@@ -84,7 +84,7 @@ <h2 class="title">C</h2>
8484
<dt><span class="memberNameLink"><a href="../pthreading/PThread.html#calc()">calc()</a></span> - Method in class pthreading.<a href="../pthreading/PThread.html" title="class in pthreading">PThread</a></dt>
8585
<dd>
8686
<div class="block">An optional override (you <i>can</i> do calculation-related code in
87-
<a href="../pthreading/PThread.html#draw()"><code>PThread.draw()</code></a>.</div>
87+
<a href="../pthreading/PThread.html#draw()"><code>PThread.draw()</code></a>, but putting it here may make more sense).</div>
8888
</dd>
8989
</dl>
9090
<a href="index-1.html">A</a>&nbsp;<a href="index-2.html">B</a>&nbsp;<a href="index-3.html">C</a>&nbsp;<a href="index-4.html">D</a>&nbsp;<a href="index-5.html">E</a>&nbsp;<a href="index-6.html">G</a>&nbsp;<a href="index-7.html">I</a>&nbsp;<a href="index-8.html">P</a>&nbsp;<a href="index-9.html">R</a>&nbsp;<a href="index-10.html">S</a>&nbsp;<a href="index-11.html">U</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a></div>

docs/index-files/index-4.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>D-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-5.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>E-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-6.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>G-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-7.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>I-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-8.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>P-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index-files/index-9.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>R-Index</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
1010
<link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
1111
<script type="text/javascript" src="../script.js"></script>

docs/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (12.0.1) on Sat Oct 12 16:13:46 BST 2019 -->
5+
<!-- Generated by javadoc (12.0.1) on Fri Oct 18 19:01:01 BST 2019 -->
66
<title>Generated Documentation (Untitled)</title>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8-
<meta name="dc.created" content="2019-10-12">
8+
<meta name="dc.created" content="2019-10-18">
99
<script type="text/javascript">window.location.replace('pthreading/package-summary.html')</script>
1010
<noscript>
1111
<meta http-equiv="Refresh" content="0;pthreading/package-summary.html">

0 commit comments

Comments
 (0)