Sign in to follow this  
Followers 0

Enhance _Singleton - Trac Ticket #2108


8 posts in this topic

#1 ·  Posted

I just noticed that Trac ticket #2108 was closed as "No bug".

I understand that the code as it is now might already be broken because it does more than originally intended.

On the other hand the change smartee proposed solved my problem (described ). I implemented and tested smartees code and it now allows to sequentially run compiled scripts an application I can't control starts in a bunch.

I think every code change that enhances the functionality of AutoIt should be welcome. In particular when its jut 2 lines of code and the risk of side effects is minimal.

I vote for implementing smartees change.

Just my 2 cents.


My UDFs and Tutorials:

UDFs:
Active Directory (NEW 2015-08-07 - Version 1.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites



#2 ·  Posted

Does more than originally intended? Yeah, it completely breaks the pattern it was designed to implement.

If that function gets touched it will be to remove the stupid behavior it should never have had. It will not receive additions to further take the function away from the singleton pattern. If you wish to implement other logic that relies on synchronization objects to limit simultaneous processes you are no longer meeting the singleton pattern and thus _Singleton() is not the right tool for the job.

I don't know why this is so hard to understand.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If you have a resource that is required by multiple jobs, you should use the API directly and maybe consider semaphores for synchronization:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682438%28v=vs.85%29.aspx

_Singelton is designed to ensure only one instance is running and is not meant for waiting.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#4 ·  Posted

I don't need the resource in my scripts. It's just used by _Singleton to do what it was designed for. I inserted the two lines to release the handle if the resource is already in use and now this modified version of _Singleton exactly does what I need.

I don't care if this breaks the intended design - I had a problem and this modification solved the problem.

I just thought this "enhancement" could be useful for others too.


My UDFs and Tutorials:

UDFs:
Active Directory (NEW 2015-08-07 - Version 1.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#5 ·  Posted

Whether it is useful or not is irrelevant. It's inappropriate for it to be in that function.

Share this post


Link to post
Share on other sites

#6 ·  Posted

That's fine for me - you are the boss.


My UDFs and Tutorials:

UDFs:
Active Directory (NEW 2015-08-07 - Version 1.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#7 ·  Posted

You know you can always include your own files with your own versions of functions.

Share this post


Link to post
Share on other sites

#8 ·  Posted

That's exactly what I do now.


My UDFs and Tutorials:

UDFs:
Active Directory (NEW 2015-08-07 - Version 1.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0