File: Finalize.sc

package info (click to toggle)
supercollider 1%3A3.10.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,496 kB
  • sloc: cpp: 283,513; lisp: 74,040; ansic: 72,252; sh: 23,016; python: 7,175; makefile: 1,087; perl: 766; java: 677; yacc: 314; lex: 175; ruby: 136; objc: 65; xml: 15
file content (27 lines) | stat: -rw-r--r-- 945 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*

Finalization is a way for the C primitives to release resources back to the system.

Rather than having a very complex system where any object can be finalized,
I have decided to centralize finalization in one class. This makes handling it in
the garbage collector very efficient.

Any class that needs finalizable data should create and point to an instance of
this class and put the data into it. This should be done from a primitive.
When the garbage collector collects this object it will call the C function you
stored in cFunction with this object as the parameter. You can also call the
finalize method to finalize on demand.

You should put your C function pointer into cFunction, and the finalizable object into 'object'.

*/

Finalizer {
	var cFunction, object; // no getters or setters!

	// no *new method! Create in a primitive.

	//finalize { _Finalize }
	notFinalized { ^cFunction.notNil }
	isFinalized { ^cFunction.isNil }
}