Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
FPC development / Improvement of TFPTimerThread.Execute
« Last post by lagprogramming on Today at 12:53:29 pm »
packages/fcl-base/src/fptimer.pp has
Code: Pascal  [Select][+][-]
  1. {$ifdef Has_EventWait}
  2. procedure TFPTimerThread.Execute;
  3. var
  4.   WakeTime, StartTime: TDateTime;
  5.   WakeInterval: Integer;
  6.   Counter: int64; { use Int64 to avoid overflow with Counter*fInterval (~49 days)}
  7.   AInterval: int64;
  8.   Diff: Extended;
  9.  
  10. Const
  11.   wrSignaled = 0;
  12.   wrTimeout  = 1;
  13.   wrAbandoned= 2;
  14.   wrError    = 3;
  15.  
  16. begin
  17.   WakeInterval := MaxInt;
  18.   Counter := 1;
  19.   AInterval := fInterval;
  20.   FStartTime := Now;
  21.   while not Terminated do
  22.     begin
  23.     if GetWakeTime(AInterval,Counter,WakeInterval,WakeTime) then
  24.       Continue;
  25.     if not Terminated then
  26.       case BasicEventWaitFor(WakeInterval,fWaitEvent) of
  27.       wrTimeout:
  28.         begin
  29.         if Terminated then
  30.           Break
  31.         else
  32.           begin
  33.           try
  34.             if not Timer.UseTimerThread then
  35.               // If terminate is called while here, then the Synchronize will be
  36.               // queued while the stoptimer is being processed.
  37.               // StopTimer cannot wait until thread completion as this would deadlock
  38.               Synchronize(@Timer.Timer)  // Call user event
  39.             else
  40.               Timer.Timer;
  41.           except
  42.             // Trap errors to prevent this thread from terminating
  43.           end;
  44.           Inc(Counter);                // Next interval
  45.           end;
  46.         end;
  47.       wrSignaled:
  48.         begin
  49.         if Terminated then
  50.           Break
  51.         else
  52.           begin                      // Interval has changed
  53.           Counter := 1;              // Restart timer without creating new thread
  54.           AInterval := fInterval;
  55.           FStartTime := Now;
  56.           end;
  57.         end;
  58.       else
  59.         Break;
  60.       end
  61.     end;
  62.   BasicEventDestroy(fWaitEvent);
  63. end;
  64.  
  65. {$ELSE Has_EventWait}
  66.  
  67. procedure TFPTimerThread.Execute;
  68.  
  69. var
  70.   WakeTime, StartTime: TDateTime;
  71.   WakeInterval: Integer;
  72.   Counter: int64; { use Int64 to avoid overflow with Counter*fInterval (~49 days)}
  73.   AInterval: int64;
  74.   Diff: Extended;
  75.   S,Last: Cardinal;
  76.   RecheckTimeCounter: integer;
  77.  
  78. const
  79.   cSleepTime = 500;           // 0.5 second, better than every 5 milliseconds
  80.   cRecheckTimeCount = 120;    // Recheck clock every minute, as the sleep loop can loose time
  81.  
  82. begin
  83.   WakeInterval := MaxInt;
  84.   Counter := 1;
  85.   AInterval := fInterval;
  86.   FStartTime := Now;
  87.   while not Terminated do
  88.     begin
  89.     if GetWakeTime(AInterval,Counter,WakeInterval,WakeTime) then
  90.       Continue;
  91.     if not Terminated then
  92.       begin
  93.       RecheckTimeCounter := cRecheckTimeCount;
  94.       s := cSleepTime;
  95.       repeat
  96.         if s > WakeInterval then
  97.           s := WakeInterval;
  98.         sleep(s);
  99.         if fSignaled then            // Terminated or interval has changed
  100.           begin
  101.           if not Terminated then
  102.             begin
  103.             fSignaled := False;
  104.             Counter := 1;            // Restart timer
  105.             AInterval := fInterval;
  106.             StartTime := Now;
  107.             end;
  108.           break;                     // Need to break out of sleep loop
  109.           end;
  110.  
  111.         dec(WakeInterval,s);         // Update total wait time
  112.         dec(RecheckTimeCounter);     // Do we need to recheck current time
  113.         if (RecheckTimeCounter < 0) and (WakeInterval > 0) then
  114.           begin
  115.           Diff := (WakeTime - Now);
  116.           WakeInterval := Trunc(Diff * cMilliSecs);
  117.           RecheckTimeCounter := cRecheckTimeCount;
  118.           s := cSleepTime;
  119.           end;
  120.       until (WakeInterval<=0) or Terminated;
  121.       if WakeInterval <= 0 then
  122.         try
  123.           inc(Counter);
  124.           if not Timer.UseTimerThread then
  125.             // If terminate is called while here, then the Synchronize will be
  126.             // queued while the stoptimer is being processed.
  127.             // StopTimer cannot wait until thread completion as this would deadlock
  128.             Synchronize(@Timer.Timer)  // Call user event
  129.           else
  130.             Timer.Timer;
  131.         except
  132.           // Trap errors to prevent this thread from terminating
  133.         end;
  134.       end
  135.     end;
  136. end;
  137. {$ENDIF Has_EventWait}





Variable "Last" is declared but never used, which means it can be removed.
Looking at variable StartTime I've noticed that when Has_EventWait is defined, the variable can be removed because it's not used at all. But then I've looked at the content of the procedure when Has_EventWait is not defined. It has just a simple assignment: StartTime := Now;. When Has_EventWait is defined the equivalent line is FStartTime := Now;. It doesn't look right. Looks like a bug, a typo. Most likely should have been "FStartTime := Now;" instead of "StartTime := Now;".
Here is a patch.
2
General / Re: Assign (textfile) not compiling - sometimes.
« Last post by Thaddy on Today at 12:18:09 pm »
That does not make these things any better. It is not Pascal.
3
Other / Re: Question for people who have built commercial apps
« Last post by marcov on Today at 12:04:56 pm »
Back around 20 years ago it was common for most major software running on the PC to be payware.  Nowadays it seems people increasingly expect programs to be free or low cost.  Is there some truth in this?

I don't think it is fundamentally just an audience thing. Of course, if there are free alternatives that are equivalent, why wouldn't they go for it? But if you can get something better suited for a reasonable price, why wouldn't you just pay it also?

So, yes, the free alternatives moved, but at the same time paid software got proportionality more expensive. In the last decade even more so due to subscription fees.

The reasons for that can only be guessed, but I think that 1995-2005 was an expansion time for software. Heaps of users entered the PC market for the first time, and market share among them mostly determined your next year's revenue.

After that, software directly marketed to end users became more a replacement market, and growing market share exponentially was less of an option and direct revenue (and thus company profitability) became more important. 

All this lead to price hikes and targeting the products at more advanced users that would pay those prices. That leads to a vicious circle where your audience becomes smaller and more price hikes are required.

As we are on a Lazarus/FPC forum, one of the ultimate examples of this kind of behaviour are the products of our direct competitor, Turbo Pascal and Delphi.  Their current commercial offerings start at Eur 1500/year. This was sub Eur 100  for an eternal license (or equivalent pre euro currency) for the cheapest, commercially usable edition a good 20 years ago.

Now there has been some inflation in that period, but not 1500%, and than I'm not even taking into account perpetual vs annual fee.


Even back then many software had free versions bundled with e.g. hardware. Scanner OCR etc, entry levels of photoshop with digital cameras etc.  route planning software with GPS equiped PDA's etc.

Quote
For those who have authored payware over the years I am wondering if you find some benefit in having a free community version instead of a trial version, and a premium paid version on top of that.  Have you gotten much benefit from this, or do you find you lose a lot of potential customers to the free version?  I am figuring increase uptake of the program would offset that.

I write software professionally for over 20 years now, but never sold boxed products to end users. Always B2B "solutions".

So we have established above that if you sell perpetual licenses, the number of users buying it will naturally decrease by year per definition in a not exponentially growing market like 1995-2005. And you still have to spend marketing to get even those.

That is where the free versions come in, these are architected so that the community version only covers one common, but occasional and basic use . People requiring the full product will have other uses/requirements that only the full product satisfied.

This essentially make the free users kind of a marketing instrument. People starting/testing the free version in companies and later upgrading, people using it are members of some club or forum related to what they are doing and tell what they are using etc.

Never make the mistake that a free user is a customer lost. Most would never have been a customer anyway. You will need to carefully craft your SKUs so that this relation between free and paid remains to not cannibalise your market.

It is a fine line that requires careful balancing. One tip that I think is smart is to make some way to end the free version. (e.g. some form of activation) Not so much to be able to take them off the market, but more to force your users always using the newest version with the conditions and limitations attached to that version. Makes the balancing easier, and allows you to correct a slip up int he balancing.

And also subscriptions. I share your dislike for them, and it is often not easy for non widely established products, but if there is something in your business model that requires annual updating of software (or its data), it might be at least an additional revenue source. Even if just at modest prices (so not pay for use, but pay for data updates), and at the same time that can be a vehicle to keep the upgrade train moving a bit, also improving revenue.
4
FPC development / Re: assembler name is longer than 16 chars
« Last post by Laksen on Today at 11:40:43 am »
You should not hardcode the assembler prefix. It should be determined automatically, or be configured by the user (The -XP<prefix> command). Just put the asmbin name as 'as'

If you need special cases try to look in "options.pas". Look for other places where utilsprefix is set
5
General / Re: Assign (textfile) not compiling - sometimes.
« Last post by Bart on Today at 11:35:37 am »
Those two do not belong there. They are simple aliases to system.assign() and system.close().
Should never have been introduced unless Delphi has them.
And of course Delphi has them, for the reason this thread makes ovious: if you use assign/close in a form's event, you'll get an error.

Bart
6
FPC development / Re: Warning: Source OS Redefined!
« Last post by Laksen on Today at 11:32:46 am »
Just do something like this. "ps1" would have to match the OS define that you create. But if you follow the same conventions otherwise it should be fine as below

Code: Pascal  [Select][+][-]
  1. initialization
  2. {$ifdef CPUMIPSEL}
  3.   {$ifdef ps1}
  4.     set_source_info(system_mipsel_ps1_info);
  5.   {$endif ps1}
  6. {$endif CPUMIPSEL}
  7.  
7
FPC development / Re: how to see what command string is passed to AS?
« Last post by Laksen on Today at 11:30:25 am »
"-sh" can be used to generate a ppas.sh file which contains the assembler command
8
General / Re: Slow copying of small structures
« Last post by alpine on Today at 11:25:10 am »
Thank you, that all makes sense.
@Alpine: It is about all operations on small structures where the compiler inserts a REP MOVSL, as in an operator or function, or when copying. Thanks for the hint with the hard types to cheat the compiler, that could be useful. In the matter at hand it won't help because the := operator is still an operator with infix notation, and the compiler will insert its REP MOVSL no matter what (inlining it does not change this).
By crafting the expression (see my last 4 lines) you can actually remove the REPs, but that's not the point. Generally, the infix operator notation will always require temporaries, hence operators are suboptimal. And fpc lacks copy constructors, static objects, etc. it's a pity.

Optimizing the copying of structures will be fantastic, but in the context of operators I doubt it will change the situation with regard to the procedures.
9
FPC development / [SOLVED] assembler name is longer than 16 chars
« Last post by Key-Real on Today at 11:15:20 am »
cpugas.pas(261,40) Warning: (treated as error) String "mipsel-unknown-elf-as" is longer than "16"
cpugas.pas(293) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted


but my AS is truely called  "mipsel-unknown-elf-as"


what to do?
10
Other / Re: Question for people who have built commercial apps
« Last post by BrassGear on Today at 11:12:50 am »
Personally I like to own something if I have to pay for it. I avoid anything with a subscription model for that reason, and another reason is the inflated cost compounded over years.
I think there are a lot of people that feel this way, but the software industry is trying very hard to move to subscriptions, for obvious financial reasons. In my opinion, it is better to support a model that favours reliability and longevity.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018