Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Enhance _Singleton - Trac Ticket #2108

_Singleton

  • Please log in to reply
7 replies to this topic

#1 water

water

    ?

  • MVPs
  • 14,970 posts

Posted 30 January 2012 - 06:44 AM

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 here). 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.

UDFs:
Active Directory (2014-02-17 - Version 1.4.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:

ADO - Wiki








#2 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 30 January 2012 - 07:11 AM

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.

#3 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 31 January 2012 - 10:57 PM

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, 31 January 2012 - 11:03 PM.

*GERMAN* Posted Image [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

#4 water

water

    ?

  • MVPs
  • 14,970 posts

Posted 01 February 2012 - 04:32 AM

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.

UDFs:
Active Directory (2014-02-17 - Version 1.4.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:

ADO - Wiki


#5 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 01 February 2012 - 04:34 AM

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

#6 water

water

    ?

  • MVPs
  • 14,970 posts

Posted 01 February 2012 - 04:42 AM

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

UDFs:
Active Directory (2014-02-17 - Version 1.4.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:

ADO - Wiki


#7 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,257 posts

Posted 01 February 2012 - 02:22 PM

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

#8 water

water

    ?

  • MVPs
  • 14,970 posts

Posted 01 February 2012 - 02:26 PM

That's exactly what I do now.

UDFs:
Active Directory (2014-02-17 - Version 1.4.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:

ADO - Wiki





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users