Core: Optimized OutStream, removed DDUMPs

git-svn-id: svn://ultimatepp.org/upp/trunk@10032 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-07-12 12:21:46 +00:00
parent ed83496a74
commit 220f751a03
6 changed files with 23 additions and 17 deletions

View file

@ -147,7 +147,7 @@ bool Stream::GetAll(Huge& h, size_t size)
String Stream::Get(int size)
{
if(size < 1024*1024) {
if(size < 32 * 1024*1024) {
StringBuffer b(size);
int n = Get(~b, size);
b.SetCount(n);
@ -1126,8 +1126,15 @@ void CompareStream::_Put(int w) {
OutStream::OutStream()
{
const int bsz = 64 * 1024;
h = new byte[bsz];
buffer = ptr = h;
wrlim = h + sizeof(h);
wrlim = h + bsz;
}
OutStream::~OutStream()
{
delete[] h;
}
void OutStream::_Put(int w)

View file

@ -521,7 +521,8 @@ public:
};
class OutStream : public Stream {
byte h[512];
byte *h;
protected:
virtual void _Put(int w);
virtual void _Put(const void *data, dword size);
@ -532,6 +533,7 @@ protected:
void Flush();
OutStream();
~OutStream();
};
class TeeStream : public OutStream {

View file

@ -1252,7 +1252,7 @@ public:
static void SetTimerGranularity(int ms);
static void Call(Callback cb);
static void Call(Function<void ()> cb);
#ifdef _MULTITHREADED
static bool IsShutdownThreads() { return Thread::IsShutdownThreads(); }

View file

@ -69,13 +69,13 @@ void Ctrl::PerformCall(Ctrl::CallBox *cbox)
cbox->sem.Release();
}
void Ctrl::Call(Callback cb)
void Ctrl::Call(Function<void ()> cb)
{
if(IsMainThread())
cb();
else {
CallBox cbox;
cbox.cb = cb;
cbox.cb << cb;
UPP::PostCallback(callback1(PerformCall, &cbox));
WakeUpGuiThread();
int level = LeaveGuiMutexAll(); // Unlock GUI to give main thread chance to handle Call

View file

@ -2667,17 +2667,18 @@ is available. [*/ This method can only be invoked in the main thread.]&]
[s7;i1120;a17; [%-*@3 ms]-|Time to sleep.&]
[s3; &]
[s4;%- &]
[s5;:Ctrl`:`:Call`(Callback`):%- [@(0.0.255) static] [@(0.0.255) void]_[* Call]([_^Callback^ C
allback]_[*@3 cb])&]
[s5;:Upp`:`:Ctrl`:`:Call`(Upp`:`:Function`<void`(`)`>`):%- [@(0.0.255) static]
[@(0.0.255) void]_[* Call]([_^Upp`:`:Function^ Function]<[@(0.0.255) void]_()>_[*@3 cb])&]
[s2; Executes a callback in the main thread (the one responsible
for GUI). It works by posting callback into timer queue (with
zero delay), then waits its completion using Semaphore. Main
GUI thread has to run timer queue management for callback to
be executed (by running event`-loop (TopWindow`::Run) or ProcessEvents).
Warning: Call unlocks GuiLock so that the main thread can run
on GUI, this is possible source of race`-conditions. Be prepared
that some other code can run on GUI between call to Call and
cb being executed!&]
Warning: Call temporarily unlocks GuiLock (if locked) so that
the main thread can run on GUI, this is possible source of race`-conditions
(GuiLock is relocked after call completes). Be prepared that
some other code can run on GUI between call to Call and cb being
executed!&]
[s3; &]
[s4;%- &]
[s5;:Ctrl`:`:IsShutdownThreads`(`):%- [@(0.0.255) static] [@(0.0.255) bool]_[* IsShutdownTh

View file

@ -66,11 +66,7 @@ void Lz4::FlushOut()
if(!pos)
return;
int clen;
{
RTIMING("Compress");
clen = LZ4_compress(buffer, ~outbuf + 4, pos);
}
int clen = LZ4_compress(buffer, ~outbuf + 4, pos);
if(clen < 0) {
error = true;
return;