Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Free Pascal / Re: FPC 3.2.x series branched, trunk update to 3.3.1
« Last post by Martin_fr on Today at 08:55:24 pm »
1) Do you need to rebuild:
- the compiler
- the rtl
- package(s)
?

packages can often be copied to a new location and recompiled. But only if you do not use other packages that depend on the one you rebuild.

the compiler...
the official answer is buildfaq.pdf

Here is how I do it (hope I make no copy and paste error)

checkout (fully recursive)
https://svn.freepascal.org/svn/fpc/trunk
https://svn.freepascal.org/svn/fpcbuild/trunk

Have ready an install (eg lazarus) of the latest released fpc.

Include in your PATH
- the installed released fpc directory
- build_trunk\install\binw32 or binw64 (and if needed crosstools)
  build_trunk is svn/fpcbuild/trunk

Make sure you do not have Delphi's make in the path.

  cd path/in/svndir/fpc/trunk
  make clean distclean
  make.exe all   OPT="-gw" 

you may want to add (at your option)
  make.exe all   OPT="-gw"  COPYTREE=echo UPXPROG=echo

then
  make.exe install  INSTALL_PREFIX=yourinstdir  COPYTREE=echo UPXPROG=echo

generate your fpc.cfg
   fpcmkcfg.exe  -d "basepath=__yourinstdir__" -o "__yourinstdir__\bin\%FPCFULLTARGET%\fpc.cfg"
2
General / Re: TTask futures Delphi equivalent under FPC
« Last post by mr-highball on Today at 08:52:45 pm »
taking your original sample, here is a program which demonstrates.

Code: Pascal  [Select]
  1. {$mode delphi}{$H+}
  2. {$ModeSwitch nestedprocvars}
  3. program test_nonblock;
  4. uses
  5.   SysUtils,
  6.   ezthreads;
  7.  
  8.  
  9. procedure A;
  10. var
  11.   B : IEZThread;//interface type
  12.  
  13.   procedure C(Const AThread:IEZThread);
  14.   begin
  15.     Sleep(1000);
  16.     WriteLn('C finished');
  17.   end;
  18.  
  19. begin
  20.   //create B using Impl class
  21.   B:=TEZThreadImpl.Create;
  22.  
  23.   //provide nested method 'C' for thread 'B' and 'Start'
  24.   B.Setup(C).Start;
  25.  
  26.   //after start is called the local reference is decremented
  27.   //but the thread will live on until method C is finished
  28.   //due to the internal design of ezthreads. to prove write to console
  29.   //that A has finished before C
  30.   WriteLn('A finished');
  31. end;
  32.  
  33. begin
  34.   A();
  35.  
  36.   //wait until thread has time to respond
  37.   Await;
  38.  
  39.   //wait for user to press something again
  40.   ReadLn;
  41. end.
  42.  

I've attached the output of the console app as well, but even the local reference has been decremented, there is an internal reference kept that isn't released until your method has completed or terminated.
3
General / Re: TTask futures Delphi equivalent under FPC
« Last post by lucamar on Today at 08:51:29 pm »
or should use a pointer to correctly nil the variable through a container?

eg.

procedure A;
var B:^iezthread;
begin
New(B);
B^:=iezthread.create;
insert B in some list
in a loop check in the list if B is terminated then Free(B)
?

No need to use a pointer, the object itself is already a reference. Unless the container needs explicitely a pointer type, that is ... in which case you should be rather using a list of objects :)
4
General / Re: Simple file with only one single record, but of HUGE size
« Last post by garlar27 on Today at 08:49:26 pm »
I think it would be much better to invest in a UPS.
I think the same since I don't know if a solid-state HD would be of any help.


The characters which fill the file are gathered/retrieved character per character with time intervals between actions getting each single character, where the intervals are neither known nor predictable. It's the fear that during the mentioned time intervals anything can happen, worst case may be power failure - although the software may run weeks the machine is not connected to an uninterruptible power supply. This whole combination led to the conclusion to fill the file character per character - to be on the safe side as each gathered character is important.

I had to deal with data loss due to power failure. Because of that you fear to loose some chars but you actually can loose the whole file if it goes corrupt !!!  :o

What we did to keep as much data as possible was start using SQLite and it slowed down the execution during data savings. SQLite is very robust against power failures because every transaction goes directly to the hard drive with the penalty it has (start moving the discs in your HD, move the headers to the location of the file/record, open the file for editing, set the new data, close the file) and though it is robust you can have a data loss but you will not have a corrupt file.
I know you are not trying to use a DB but look these links https://www.sqlite.org/about.html  and https://www.sqlite.org/transactional.html reading those pages might show you what problems are you facing on the "anything ca happen" part of your problem.



It looks like you are getting data from a sensor in a remote place (were none is around). If not, the problem is basically the same. If the data is generated inside the pc (f.i. random numbers, a simulation or what ever you can imagine) then you will lose something, if it comes from a external hardware then if the hardware has a persistent buffer then maybe you can recover something.

I would go for a partitioned file model like described before.
But for taking a decision, I think it is important to know when how and at which rate it is acquired.
 . How many chars per second? (average Bytes per second, minute, hour)
 . Is sort of "regular"? f.i. more or less every 50 milliseconds
 . Is it VERY irregular? f.i. hours of low or no activity and then it burst to 50 million chars per second
just the first ones that come to my mind. the rate at which the data is acquired might help you to chose the best approach.
5
General / Re: TTask futures Delphi equivalent under FPC
« Last post by bobdp on Today at 08:48:18 pm »
or should use a pointer to correctly nil the variable through a container?

eg.

procedure A;
var B:^iezthread;
begin
New(B);
B^:=iezthread.create;
insert B in some list
in a loop check in the list if B is terminated then Dispose(B)
?
6
General / Re: Is Lazarus supports WireCompression in Firebird 3?
« Last post by lucamar on Today at 08:47:40 pm »
Beside, do you know what library to include in the same application folder in Linux?

Unless there is a special need, don't install in the application folder. Instead install the package, which is:
Code: Bash  [Select]
  1. lucamar@selene:~$ aptitude search zlib1
  2. i   zlib1g                          - Biblioteca de compresión, ejecutables    
  3. p   zlib1g-dbg                      - Biblioteca de compresión, símbolos de depuración
  4. i   zlib1g-dev                      - Biblioteca de compresión, símbolos de depuración
  5.  

But yes, the library file itself is called libz.so
7
General / Re: Simple file with only one single record, but of HUGE size
« Last post by 440bx on Today at 08:33:19 pm »
But then you must close the file after writing each character and reopen it when the next character is to be written. And hope that the OS buffers already have been flushed. In total, this will make it even slower (what is the rate at which the characters arrive?)

I think it would be much better to invest in a UPS.
I agree, a UPS sounds like a better and more reasonable alternative.

If investing in a UPS isn't in the cards then, he should open the file specifying FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH, that would eliminate the need to either FlushFileBuffers or closing and re-opening the file after every character is written to it (both inefficient and time consuming operations.)
8
General / Re: Modify XML Node Text
« Last post by lucamar on Today at 08:07:33 pm »
Hi, I just want to change node value. Thanks.

Then use the function ReplaceChild() instead of AppendChild() (in line 14). You'll have to add some more code, though to create the new text node before calling ReplaceChild()

It's a pity that fcl-xml is almost completely undocumented (only in the wiki) :(
9
General / Re: TTask futures Delphi equivalent under FPC
« Last post by bobdp on Today at 08:05:55 pm »
procedure A;
var B:IEZThread;
begin
B:=IEZThread.Create;
B.Start;
end;

does this works correctly and B is cleaned/free on finish also if the variable is out of scope?
10
General / Re: Is Lazarus supports WireCompression in Firebird 3?
« Last post by dsiders on Today at 07:54:18 pm »
Beside, do you know what library to include in the same application folder in Linux?

I'm not a Linux guru... but I think it should be called libz.so.
Pages: [1] 2 3 ... 10