Commit Graph

38 Commits

Author SHA1 Message Date
rdb 1b67931f16 express: invert return value of unref_if_one()
This is more consistent with how the return value of unref() works.  Someone might otherwise trip over this.
2020-03-14 14:59:20 +01:00
rdb c5c1d4557b pgraph: fix double free if weak ptr to state is locked while being gc'ed
Fixes #499
2020-03-10 12:10:23 +01:00
Sam Edwards 7790f8429d general: Fully qualify header references into the std namespace
Closes #341
2018-06-07 10:35:12 +02:00
Sam Edwards e2b4353800 general: Replace NULL (and 0 as pointer) with C++11 nullptr
Exceptions to this replacement are:
- .c files
- Headers included by a .c file
- stb_image.h
- dr_flac.h
- Strings
- Comments
2018-06-03 16:35:13 -06:00
Sam Edwards d422d74abb general: Clean up asserts which were abusing NULL 2018-06-03 16:26:44 -06:00
rdb f2d429b817 express: weakptr.lock() should return null during object destruction
This came up in #330; the Character destructor caused something to call lock() on a weak pointer to that character, which would induce a ref() and unref() pair, but since the refcount was 0, this would call the destructor and thereby create infinite recursion.

I considered instead calling mark_deleted() inside unref() so that the callbacks get to run before the object is actually deleted, and was_deleted() will become true as soon as unref() reaches 0.  However, this would require grabbing the lock in unref() to be fully thread-safe, since we would need to bring the refcount to 0 and mark the object as deleted in one atomic operation, so this would be an unacceptable general performance penalty.

Instead, WeakPointerTo::lock() now atomically increments the reference count if it is not already zero, and returns null otherwise.  This should be safe because the object cannot be deleted while the WeakReferenceList lock is held.
2018-05-27 15:37:03 +02:00
rdb 0bb81a43c9 express: make a thread safe weak pointer implementation (#321)
To access a WeakPointerTo in a thread-safe way, use something like this:

    if (auto ptr = weak_ptr.lock()) {
      ..use ptr as regular PointerTo
    }

The new implementation no longer needs a reference to be stored to all weak pointers on the WeakReferenceList; a mere count of weak pointers is sufficient.  Therefore, callbacks theoretically no longer require a WeakPointerTo to be constructed.

The WeakPointerTo class is not actually atomic; it could be made so, but I don't believe it's worth it at this time.
2018-05-15 13:40:21 +02:00
tobspr 0fcfb8e372 New file headers, new comment style 2016-02-17 17:47:48 +01:00
rdb 18ad6d1543 Replace many int params with size_t params where appropriate, and work towards fixing type conversion warnings 2015-10-07 18:58:26 +02:00
rdb 265bf42f81 Fix crash when copying a WeakPointerTo that was already deleted 2015-07-28 13:41:26 +02:00
rdb 9513046e59 Various substantial changes to Interrogate:
* Allow arbitrary selection of optional keyword arguments in some cases
* Reduce code bloat of generated bindings
* Work around awkward resolution of set_shader_input overloads
* Document the code a bit better
* Make coercion a bit cleaner for reference counted types
* A few optimization tweaks
* Use generic errors in NDEBUG build to reduce size of string pool
2015-02-15 13:48:13 +01:00
David Rose 539b61571c guarantee word alignment for AtomicAdjust stuff 2011-11-17 23:31:31 +00:00
David Rose aefe3d35c2 merge dev_bam_2009 to trunk 2009-06-10 17:54:40 +00:00
David Rose fb9c56432a we are now using the modified BSD license 2008-05-28 18:37:20 +00:00
David Rose 68cd3322a9 better thread protection in reference counts, esp. TransformState etc. 2007-07-14 21:32:48 +00:00
David Rose 57338ee24d better windows tau support; better threaded DeletedChain support; beginning PipelineReader classes 2006-04-20 04:03:16 +00:00
David Rose 1eb1b26006 tau on windows 2006-04-14 03:18:36 +00:00
David Rose 1fabf70443 add ObjectDeletor; avoid unnecessary locks on RenderState 2006-04-10 21:19:48 +00:00
David Rose 889228f403 name mutexes for debugging; better UpdateSeq thread behavior 2006-04-09 23:23:15 +00:00
David Rose 8a78fffd8f multithreading optimizations, tau profiler, related changes 2006-04-05 19:36:05 +00:00
David Rose 1d2282a879 pipelining getting close; uprev bam version to 6.0 2006-02-14 19:07:47 +00:00
David Rose 0bd34f9f4b runtime improvements 2005-05-10 22:43:44 +00:00
David Rose 05ba41b4d6 add ReferenceCount::local_object(), clarify GeomVertexCache 2005-04-17 17:38:51 +00:00
David Rose e91e72e6c5 fix memory leak in state cache 2005-01-26 01:06:39 +00:00
David Rose 557060cb1d weak pointers, and FadeLODNode fixes for instances/multiple cameras 2004-09-30 21:29:25 +00:00
David Rose 62fb0d3011 rework comments 2004-07-19 14:37:29 +00:00
David Rose 843c0331ae update license, change remaining local #includes to use quotation marks 2004-02-13 19:27:33 +00:00
David Rose 58b5397d87 first pass at new ipc 2002-08-09 22:58:13 +00:00
cxgeorge 48fbbe3aac add DO_MEMORY_USAGE 2002-02-06 01:50:07 +00:00
cxgeorge 31529c37fa remove O4 memusage calls 2002-01-17 01:44:58 +00:00
David Rose 2f4e207edb Update copyright header 2001-05-25 21:27:38 +00:00
David Rose fcb24f02ef remove tab characters 2001-05-25 15:56:49 +00:00
cxgeorge fb6ca6a160 many micro-optimizations 2001-05-24 02:55:11 +00:00
David Rose 7082cc10e3 *** empty log message *** 2001-05-10 18:55:21 +00:00
David Rose faa13d10e5 *** empty log message *** 2001-01-09 03:07:29 +00:00
David Rose 7d38626876 *** empty log message *** 2000-11-17 04:49:21 +00:00
David Rose d9730bb878 *** empty log message *** 2000-10-17 21:45:27 +00:00
David Rose 2fd714e52f Initial revision 2000-10-04 01:14:41 +00:00