We now keep track of a lower bound as to when the list should scale
itself back down. When increasing the list size, we double the current,
with the lower bound set to 1/4 of the current size, not allowing it to
go any smaller than the block size. These combined allow us to do very
cheap tests to see if an operation requires a resize at all, and minimize
how often the list actually needs to be resized, since the difference in upper
and lower bounds prevents bouncing back and forth between a size in the case
of adding/removing an item while close to a boundary. All in all this should
make BList noticably more scalable when doing large numbers of add/remove
operations.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25946 a95241bf-73f2-0310-859d-f6bbb57e9c96
compile time checks. Incidently those are not totally uncommon in
portable code.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25385 a95241bf-73f2-0310-859d-f6bbb57e9c96
* _Alloc() can now preserve the original reference count, only _Clone()
still initializes it to 1. As Karsten pointed out, this is necessary to
preserve the "shareable" status of the private data.
* I hope that's finally it. What happened to our testing suite, anyway? :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24355 a95241bf-73f2-0310-859d-f6bbb57e9c96
_ReplaceAtPositions(), and _DoCharacterEscape() (we don't need to preserve
it, though, as it must be 1).
* Factored out an _Alloc() method which is now always called when the private
data is allocated. It also takes care of correct initialization (and thus
fixes the above problem).
* This fix finally allows turning on reference counting again, thanks Karsten!
* Minor cleanup, renamed "oldAdr"/"newAdr" to "oldString", resp. "newString".
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24348 a95241bf-73f2-0310-859d-f6bbb57e9c96
copy constructors, effectively turning of references completely.
* Since that caused troubles (NetPositive now crashes when started), I
temporarily disabled references by letting _IsShareable() always return
false until the issue is resolved.
* _FreePrivateData() now sets the fPrivateData member to NULL, and is also
safe to be called when fPrivateData is NULL.
* Removed my comment about the threading problem in _Detach() and _DetachWith()
as that just couldn't happen.
* _Clone() must not use memcpy() as the string pointed to by "data" might not
be as long as "length".
* LockBuffer() now marks a string as unshareable.
* Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24345 a95241bf-73f2-0310-859d-f6bbb57e9c96
string stuff.
* It's still not thread-safe for all usage patterns, though, so we might want
to remove or disable it: if a string is shared between several threads, and
one of those starts to use a reference, all kinds of problems can happen.
* Some cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24312 a95241bf-73f2-0310-859d-f6bbb57e9c96
with gcc 4. Fixed resulting build errors (gcc is more lenient for
headers in -isystem directories).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20386 a95241bf-73f2-0310-859d-f6bbb57e9c96
C style ones, as this is a C header, too (and a very basic one).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19984 a95241bf-73f2-0310-859d-f6bbb57e9c96
feel free to change that ;-)
* Cleaned up existing headers.
* Coding style guide update to BBufferIO (renamed m_* members to f*).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19972 a95241bf-73f2-0310-859d-f6bbb57e9c96
It's hopefully now used everywhere instead of B_RAW_TYPE where appropriate.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19219 a95241bf-73f2-0310-859d-f6bbb57e9c96
Position(). This used up a virtual slot of BPositionIO. GetSize() needed to be
implemented in BFile, which uses the BStatable version as before. This should
hopefully be binary compatible. The only problem could be in source
compatibility when there are classes inheriting from BPositionIO implementing
their own GetSize().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17593 a95241bf-73f2-0310-859d-f6bbb57e9c96
- B_SHUTDOWN_CANCELLED: The shutdown process was cancelled (most likely by
the user).
- B_SHUTTING_DOWN: An operation cannot be performed, since the system is
shutting down (e.g. BApplication creation).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13413 a95241bf-73f2-0310-859d-f6bbb57e9c96
Fixed the remaining references to that header in our repository.
Note, this might break source compatibility - please update your sources :-)
Slightly converted UBS_audio_utils.c to use our style guide while I were at it.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12827 a95241bf-73f2-0310-859d-f6bbb57e9c96
- SupportDefs.h only includes stdbool.h if included from C
- stdbool.h for C++ now includes a macro for "bool" as defined by that header
- stdbool.h does nothing if __bool_true_false_are_defined is already defined
- stdbool.h no longer defines a _Bool enum, but defines _Bool as unsigned char, as
previously done by SupportDefs.h (the previous version changed the size).
- The gensyscalls Jamfile now preprocesses its headers in C++ mode so that "bool"
stays "bool", and doesn't become _Bool.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12042 a95241bf-73f2-0310-859d-f6bbb57e9c96
SupportDefs.h now includes stdbool.h
This can break in some cases
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11985 a95241bf-73f2-0310-859d-f6bbb57e9c96
Code is refactored, and it fully complies with our guidelines.
Tests have been updated too (hint: try the replace tests with R5 and our implementation...)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5348 a95241bf-73f2-0310-859d-f6bbb57e9c96
renamed user_??? functions into the new _user_??? naming style.
changed implementation of PPC 64 bit atomic functions to use (un)lock_memory()
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4417 a95241bf-73f2-0310-859d-f6bbb57e9c96
According to the BeBook, it is NOT allowed to allocate one large
pool, instead the memory blocks must be allocated individually.
To achieve O(1) for both Save() and Get() function, only one list
of free blocks is maintained.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4393 a95241bf-73f2-0310-859d-f6bbb57e9c96
function from this public header, since it's not safe, and it's slower than parsing bytes one by one.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4006 a95241bf-73f2-0310-859d-f6bbb57e9c96