[REQ] Content plugin model update

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

[REQ] Content plugin model update

Post by *majkinetor ! »

onRefreshStart()
Called before first request

onRefreshEnd()
Called after TC have finished displaying/searching.


This is 4 minutes work for you ghisler... Just put 1st func before FileNext loop and 2nd after.... and thats it.
Habemus majkam!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Any words, Ghisler ?
Habemus majkam!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50421
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

In principle, the idea is good, and such functions were also part of the interface when I first designed it. But unfortunately it's much more complex than what you may think: The content plugin interface supports synchronous and asynchronous retrieval of the plugin values. Asynchronous means that the data is retrieved in a background thread. Therefore the data requests can come in a mixed mode for the two panels, and even for separate dirs when using branch view.

This is also described in detail in the content plugin help file:
About caching the data: Total Commander will not call a mix ContentGetValue for different files, it will only call it for the next file when the previous file can be closed. Therefore a single cache per running Total Commander would be sufficient. However, there may be other calls to ContentGetValue with requests to other fields in the background, e.g. for displaying result lists. There may also be multiple instances of Total Commander at the same time, so if you use a TEMP file for storing the cached data, make sure to give it a unique name (e.g. via GetTempFileName).
An idea to decide whether to cache data or not is to measure the elapsed time (GetTickCount). If there has been more than a second since the last request, it's better to verify whether the data has changed or not.
Author of Total Commander
https://www.ghisler.com
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

What about transmiting thread ID ?
In DELPHI u can set this argument to have default value of 0 meaning this value is not important so current plugins unaware of threads are compatibile.
Habemus majkam!
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
An idea to decide whether to cache data or not is to measure the elapsed time (GetTickCount). If there has been more than a second since the last request, it's better to verify whether the data has changed or not.
This is not a reliable solution. Please implement such a mechanism.
http://www.ghisler.ch/wiki/index.php/Info_about_refresh
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50421
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I could send such a notification, but I couldn't guarantee that there aren't any ongoing calls to the plugin in the background list. The refresh call could even occur at the same time as a background call, which could crash the plugin if it discards the cache in that moment...
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
I could send such a notification, but I couldn't guarantee that there aren't any ongoing calls to the plugin in the background list. The refresh call could even occur at the same time as a background call, which could crash the plugin if it discards the cache in that moment...
The plug-in is responsible for synchronizing access to its resources.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

What about thread ID ?

onRefreshStart ( threadID: HANDLE )
Called before first request for thread

onRefreshEnd( threadID: HANDLE)
Called after TC have finished displaying/searching in thread
The plug-in is responsible for synchronizing access to its resources.
right !
Habemus majkam!
Post Reply