What is the lowest overhead way to limit executing one section of code to 4

In a single app we need to limit executing a section of code to 4 threads. This section is not the start/end of the thread, it is a section of code inside the thread.
So what is the most light-weight way to do this when all threads are in a single app? Semaphore?
Background: We are changing our licensing model to allow a maximum of N (4 in this example) threads calling our library consecutively. Because we're a library, not a server, we don't control the thread usage (like databases can). In the case of a web app, the calling app also doesn't control the number of threads and so we need to pause thread 5 calling us until one the first 4 exit that code.

Since the API docs for Semaphore say
Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource.that would seem to be the answer.

Similar Messages

  • What is the most efficient way to turn an array of 16 bit unsigned integers into an ASCII string such that...?

    What is the most efficient way to turn a one dimensional array of 16 bit unsigned integers into an ASCII string such that the low byte of the integer is first, then the high byte, then two bytes of hex "00" (that is to say, two null characters in a row)?
    My method seems somewhat ad hoc. I take the number, split it, then interleave it with 2 arrays of 4095 bytes. Easy enough, but it depends on all of these files being exactly 16380 bytes, which theoretically they should be.
    The size of the array is known. However, if it were not, what would be the best method?
    (And yes, I am trying to read in a file format from another program)

    My method:
    Attachments:
    word_array_to_weird_string.vi ‏18 KB

  • What is the Aperture 3 library volume limit?

    When I attempt to import photos from my Nikon D90 into Aperture 3 I receive the following message:  There is not enough free space on your Aperture Library volume to import the selected items. It is estimated that you need at least 333MB of additional free space.
    I have about 10GB of free space on my HD so seemingly the volume limit appears to be specific to the software itself.  What is the volume limit in Aperture 3?  Assuming I have reached the limit, what are the suggested best ways to store folders or free up a sizeable amount of space within Aperture?
    Justin

    Justin-
    Hard dries slow as they fill and become unstable at some unknown point; handling large chunks of data can become problematic. And less-than-ideal RAM will exacerbate HDD issues.
    As a guideline I strongly recommend not exceeding ~70% full. Having just 10 GB free HDD space you are asking for a data-destroying crash. You should offload data to an external drive immediately. Do not try to work until you have at least 100 GB free space on that internal HDD.
    Of course often a boot drive will still function 90+% full, but not always. And overfilled HDDs are always slow.
    Hard drives are dirt cheap now. There is no reason to put data at risk by overfilling hard drives.
    Solid State Drives (SSDs) do not suffer from the same limitations as HDDs but still need some free space available.
    23k D90 photos is not very many. Buy a 2-TB external hard drive and reference the photos to your external HDD by (from within Aperture) relocating the originals/Masters to the external HDD. In addition original image files must be separately backed up to yet another drive. In the future do that backup of originals before importing into Aperture.
    HTH
    -Allen

  • What is the best overhead projector for a new 13" MacBook Pro

    What is the best overhead projector for a new retina display macbook pro?

    The key issue you should be worried about is what's the best projector for the intended room/environment/audience you will be projecting from/to. The Mac is just a content provider and will always exceed the resolution capabilities of all projectors in the market so will have to downgrade its output to suit their reduced capabilities. 
    Only thing you may want to make sure is that the projector have digital HDMI input. That way you can plug the Retina in with just a cable and not need to purchase any intervening adapter dongle prone to failure or misplacement.

  • I have an ipod classic with 4gb, it is full. What is the most economical way to upgrade to at least 16gb

    I have an ipod classic with 4gb, it is full. What is the most economical way to upgrade to at least 16gb?
    (I don't want to delete anything)

    To recover the photos from an iPod Classic you'll need to use third-party software and the photos gained will be quite low resolution.
    See https://discussions.apple.com/docs/DOC-3991 for possibilities.

  • What is the Infinity option 2 usege limit?

    hello all.
    what is the Infinity option 2 usage limit? is it 100gb or 300gb? a month.
    cos its been 5 days now I'm getting very bad speed, 2 mb down and  .8mb up after 6 pm till 2am. this is absolutely rubbish paying £24.99 a month for this **bleep**!! and i cant even watch anything  online!!
    regards
    Ben
    Solved!
    Go to Solution.

    zodfsx wrote:
    hello all.
    what is the Infinity option 2 usage limit? is it 100gb or 300gb? a month.
    cos its been 5 days now I'm getting very bad speed, 2 mb down and  .8mb up after 6 pm till 2am. this is absolutely rubbish paying £24.99 a month for this **bleep**!! and i cant even watch anything  online!!
    regards
    Ben
    Hi Ben.
    The threshold figure is 300GB per month.
    Click https://www.bt.com/appsyouraccount/secure/cyahub.do and enter your bt.com associated login ID and password (if it doesn't already let you in). The ID needs to be associated with your BB phone number.
    Go down to Manage your services, click the Broadband tab, and then choose View your broadband usage.
    http://www.andyweb.co.uk/shortcuts
    http://www.andyweb.co.uk/pictures

  • What is the lowest prices for an ipod touch 5th generation yellow

    what is the lowest price for a new ipod touch 5th generation 32 gb yellow pink and blue

    Google and find out. It is a moving target.

  • HT1476 What is the absolute best way to recharge my iPhone 5S?

    What is the absoulute best way to charge and discharge my iPhone 5S?  Should I wait until the battery is below a certain percentage level before recharging?

    Plug it in anytime you desire.
    Charge it until you are ready to unplug it, then do so.
    The only no-no is allowing the device to completely discharge.

  • What is the lowest ISE version supported with WLC 7.3.112.0

    Dears
    Kindly i want to know what is the lowest version of ISE supported with WLC 7.3.112.0 or WLC 7.3.101.0
    Please need your feedback.
    Regards,

    the lowest version of ise supported wlc 7.3 is ISE 1.2 as per document :
    Wireless LAN Controller (WLC) 2500 8
    7.3.112.0.(ED), 7.4.x, 7.5
    Yes 9
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Wireless LAN Controller (WLC) 5500 8
    7.3.112.0.(ED), 7.4.x, 7.5
    Yes 9
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Wireless LAN Controller (WLC) 7500 8
    7.3.112.0.(ED), 7.4.x, 7.5
    Yes 9
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    No
    Yes
    Wireless LAN Controller (WLC) 8500 8
    7.3.112.0.(ED), 7.4.x, 7.5
    Yes 9
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    No
    Yes
    http://www.cisco.com/c/en/us/td/docs/security/ise/1-2/compatibility/ise_sdt.html
    ISE 1.1 won't support wlc 7.3 :
    http://www.cisco.com/c/en/us/td/docs/security/ise/1-1/compatibility/ise_sdt.html
    Wireless LAN Controller (WLC) 2100, 4400
     7.0.116.0
     No6
     Yes
     No
     Yes
     Yes
     Yes
     Yes
     No
     No
     Wireless LAN Controller (WLC) 2500, 5500
     7.2.103.0
     No6
     Yes
     Yes
     Yes
     Yes
     Yes
     Yes
     Yes
     No
     WLC 7500 Series
     7.2.103.0 (basic RADIUS auth supported in 7.0.116.0)
     Yes6
     Yes
     No
     Yes (local only)
     No
     Yes
     No
     No
     No

  • What is the most effective way to write Statement to catch and reverse errors during query excution?

    Hello my friends:
    I am wondering what is the most effective way to deal with errors, specifically in a
    Stored Procedure.
    I wrote something like this:
    BEGIN TRY
    BEGIN TRANSACTION
    /*My statements goes in here*/
    IF ERROR_NUMBER() = 0 -- Do I need this line?
    COMMIT TRANSACTION;
    END TRY
    BEGIN CATCH
    IF ERROR_NUMBER() > 0 --Do I need this line?
    ROLLBACK TRANSACTION;
    END CATCH;
    It would make sense using the if Statement when attempting to log errors.
    Just too many variations.
    Thanks

    Also read this great article
    http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/05/13/your-try-block-may-fail-and-your-catch-block-may-be-bypassed.aspx
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • What is the lowest version of acrobat that supports interactive PDFs

    what is the lowest version of acrobat that supports interactive PDFs

    As noted one can go back to PDF level version 1.2 but the forms need to be created with Acrobat and any JavaScript has to avoid using any features added with version 4 or above.

  • What is the most efficent way to create both a standard and HD DVD

    Hi,
    I'm just getting into HD video editing, and I have relatives who will be several years behind me. I will be making HD DVD's for myself to use, but I will also need to make standard DVD's to send to my relatives.I am assuming that the HD DVD's I create will not play in a standard DVD player. I may be wrong. However, If this is correct, is there a particular point in the process of working with Encore where I can make that choice, create the DVD, and then go back and alter it in order to create the other type without destroying and having to redo everything that was done up to that point?

    Thank you Hunt. Being ahead of most of the rest of the world and getting the best technology out there can be a pain sometimes. Reading through Jon Geddes' article left me scratching my head several times, and some of it went way over my head, but I'll keep at it, until it sinks in. Some language, terms, and shorthand, I'm sure are simple to understand to a lot of people, but I'm not in that catagory. I'll just keep working at it. 
    Terry Lee Martin
    Date: Sun, 18 Oct 2009 13:39:08 -0600
    From: [email protected]
    To: [email protected]
    Subject: what is the most efficent way to create both a standard and HD DVD
    I would edit the Project in HD in PrPro. The BD authoring part will be straight workflow.
    For the SD DVD-Video, you have a few choices. You can Export to DV-AVI Type II for Import into a new Encore Project for the DVD. Some feel that PrPro does not do a good job at down-rezing from HD to SD. For a workflow that will likely yield better quality, see this http://www.precomposed.com/blog/2009/07/hd-to-sd-dvd-best-methods/. If you have PrPro/Encore CS4, then Jeff Bellune's /thread/487134?tstart=0 might be useful to you. Just follow the links to the tutorial.
    Good luck,
    Hunt
    >

  • What is the best, cheapest way to upgrade from CS3 MAC to a newer CS for PC

    What is the best, cheapest way to upgrade from CS3 MAC to a newer CS for PC? I do graphic desing mostly print and some web and want to get into ebooks and more web graphics?

    Hi riverwalk2,
    I have check & found Design Standard CS3 that you have might be eligible for few special offer for the latest version of Adobe Creative Cloud which is independent of Operationg systems.
    Please choose the best option in http://www.adobe.com/products/discount-software-coupons.html?promoid=KAWQR
    Hope it helps you,
    Regards,
    Rajshree

  • What is the least expensive way for me to upgrade from CS version 8 and buy InDesign too?

    What is the least expensive way for me to upgrade from CS version 8 and buy InDesign too?

    Unfortuneately, a full Creative Cloud subscription at $40/month, or buy the CS6 versions outright.

  • What is the easiest/quickest way to upload a just-taken picture to Facebook?

    What is the easiest/quickest way to upload a just-taken picture to Facebook?

    Open the Facebook app on your iPhone and select Photo, select Choose from Library, etc.

Maybe you are looking for