Commit Graph

17 Commits

Author SHA1 Message Date
rdb fe1bfef5c0 express: fix a few compile errors with certain WeakPointerTo uses
Fixes #367
2018-07-31 14:02:58 +02:00
rdb 243ee75e47 express: refactor WeakPointerTo::lock() a little bit 2018-07-30 22:24:55 +02:00
rdb ad3ab3ad21 Define stable ordering for WeakPointerTo for use as map/set key
Currently, the WeakPointerTo comparison operators compare the raw pointers, but this is not useful as it may cause a false equality if one weak pointer in the comparison is expired and points to memory that has since been reused.

Instead, we can define a comparison based on the control block pointer, which exists since the new weak pointer implementation in 0bb81a43c9.  This is implemented in the owner_before method, matching C++11 std::weak_ptr semantics.

I would now recommend deprecating most comparison operators of WeakPointerTo or redefining them to make more sense, ie. comparing equal if they (once) referred to the same object and not if they simply point to the same memory address.  This has not yet been done, though code that uses the comparison operators has been fixed in this commit.

Overloads of std::owner_less have been provided for creating a map or set with Weak(Const)PointerTo keys.
2018-07-30 17:27:09 +02:00
rdb 2d7e80a89e express: add full range of WeakPointerTo ctors and assign ops
Matches PointerTo constructors/assignment operators, supporting conversion between related pointer types.

Fixes #367
2018-07-30 17:26:02 +02:00
rdb fb82a1c557 express: enable WeakPointerToBase comparison operators on Win32
I'm not sure why they were ifdeffed out, but they should certainly be available so that it is possible to compare WeakPointerTo in a thread-safe manner.
2018-07-08 21:22:25 +02: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 f0fc6e6d56 express: Fully qualify std::nullptr_t 2018-06-03 16:56:53 -06:00
Sam Edwards ebe1b0763f express: Allow WeakPointer comparisons to nullptr
This saves us from having to do casts like:
if (foo == (const FooType *)nullptr) {
  ...
}
2018-06-03 16:26:44 -06:00
rdb 9fad3dba60 general: remove macros for compatibility with non-C++11 compilers
Now that we require MSVC 2015, we no longer need all this nonsense, so we can write cleaner code.
2018-05-23 23:33:05 +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
Chris Brunner c87f384a40 fixes for 32 and 64-bit builds both being able to build 2010-05-28 23:22:43 +00:00
Chris Brunner 547a72053c support for #ifdef WIN64_VC instead of just #ifdev WIN32_VC alone 2010-05-28 21:09:22 +00:00
David Rose fb9c56432a we are now using the modified BSD license 2008-05-28 18:37:20 +00:00
David Rose 7c9997118c support common transforming of shared PartBundles 2007-10-03 21:14:33 +00:00
David Rose 475196cbef robustify WeakPointerTo, publish ConstPointerTo 2005-03-11 19:29:57 +00:00
David Rose 557060cb1d weak pointers, and FadeLODNode fixes for instances/multiple cameras 2004-09-30 21:29:25 +00:00