Viktor,
Maybe I'm missing something, but I don't see why this needs
to be made that complicated. Windows already stores lasterror
in thread-local storage. Unless someone wants to use threads
created by non-Harbour means, storing lasterror for all
CPU threads inside every Harbour threads seems unnecessary.
Complicated is for me to understand why you say "every Harbour threads" and
repeat.
details, I don't understand why storing an array of thread
ID/lasterror pairs into _every_ Harbour thread is useful.
Only activating HB_TRACE() with any example of /test/mt and adding
wapi_SetLastError() you can see that this is not true.
Just store only a single ID/lasterror pairs by thread and these pairs can be
made easily accessible from another thread.
I think that C don't have the problems of spoken language such as English.
But sorry, I use my code resources made before and It's maybe the reason for
not having seen another solution for Harbour.
Code also uses a 'goto', which should IMO be replaced by
some other coding method.
This is new for me, goto is a C99 resource, I use with macros that generated
label/goto: something like this .-
#define CHKPTR( x ) if( !(x) ) do{ goto __func__##Error; }while( 0 )
#define FUN_ERROR goto __func__##End; __func__##Error:
#define FUN_END __func__##End:
void Anyfunction( void )
{
void *pPtr;
CHKPTR( pPtr = malloc(16) );
...
...
...
FUN_ERROR
...
FUN_END
if( pPtr ) free( pPtr );
}
For me it's more easier to read, understand and maintain.
It stayed in the adapting to Harbour but I suppose that it's a new coding style
standard in Harbour.
* contrib/hbwin/wapi_winbase.c
+ Added hbwin_SetLastError(), hbwin_GetLastError()
low-level functions to save/get GetLastError() values.
This is required to preserve win lasterror value on .prg
level. The reason we need this is because TlsGetValue()
(called internally by Harbour core) is overwriting this
value. Thanks to Xavi for research.
Thanks to you and my sincere congratulations on your code, is better for
Harbour of course.
I don't have objection to change or replace my code with a code better, if not
I don't be released public but
_I am absolutely disagree because the changes are not made in the repository_.
I'd like to ask you to request R/W access on public
mailing list, it's not my personal project. It'd also be
good if other developers could also review this patch.
I've done and not just in this thread. I don't like the answer, no direct answer for to be accurate, but indirect understand and
it's obvious that my feelings are not the same as before. I sincerely hope to have contributed to solve the issue.
Sorry for the inconvenience and appreciate your patience.
Thank you.
Best regards.
--
Xavi
El 02/01/2010 18:28, Viktor Szakáts escribió:
Hi Xavi,
On 2010 Jan 2, at 17:47, Xavi wrote:
Viktor,
I have implemented the support in wapi_* for Windows API LastError.
I think that I should do the job of updating the repository, thank you very
much for doing before, I hope to consult you my doubts.
Does the ChangeLog file is automatically updated with the Message cangelog or
should we update it explicitly?
You need to modify it manually. Please read doc/howtosvn.txt.
I installed the TortoiseSVN and prepared the following update, I hope it's
correct.
Please, could you grant acces to ID jarabal in sourceforge.net
Message cangelog .-
* contrib/hbwin/hbwapi.h
+ added wapi_StoreLastError() declaration.
Since this is a low-level hbwin specific function
(or rather subsystem), please name it hbwin_StoreLastError()
and place implementation in new file win_err.c.
* contrib/hbwin/wapi_winbase.c
* moved wapi_SetLastError() and wapi_GetLastError()
to wapi_winbase_mutex.c
Please leave them in wapi_winbase.c. Each wrapper
should stay in the source which implements a given
set of functions, for WAPI_SET/GETLASTERROR() this is
wapi_winbase.c, since Set/GetLastError() Windows API
functions are declared in winbase.h. See:
http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx
* contrib/hbwin/wapi_winbase_mutex.c
+ Added support for Windows API LastError in ST/MT mode.
All functions wapi_* that can be used GetLastError()
should be stored the value using wapi_StoreLastError().
wapi_GetLastError() return the stored value by threads
before direct value of GetLastError().
Maybe I'm missing something, but I don't see why this needs
to be made that complicated. Windows already stores lasterror
in thread-local storage. Unless someone wants to use threads
created by non-Harbour means, storing lasterror for all
CPU threads inside every Harbour threads seems unnecessary.
Code also uses a 'goto', which should IMO be replaced by
some other coding method.
+ Added new PRG function .-
nSizeThrs := wapi_HB_WorkSpaceSLE( [nSizeIncThrs] )
By default wapi_StoreLastError() stores and increases every 256 threads,
can be increased, view or cancel the storage with nSizeIncThrs parameter.
nSizeIncThrs == -1 cancel the storage for debugging tests.
nSizeIncThrs == 0 or nil returns the current value.
This value can be increase with nSizeIncThrs greater than current value.
Should be named WIN_WORKSPACESLE() although IMO
this is the sort of low-level detail which should work
automatically without any .prg function which
requires programmers attention. 999 out of 1000 programmer
will not understand what is this, even less ppl
will know how and when to use it. I suggest to delete it
and simply set some good defaults.
Missing from the patch is setting lasterror from all
such existing WAPI_* wrappers which may also set lasterror.
I'd like to ask you to request R/W access on public
mailing list, it's not my personal project. It'd also be
good if other developers could also review this patch.
Brgds,
Viktor
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour