{"id":11033,"date":"2011-04-05T07:00:00","date_gmt":"2011-04-05T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/04\/05\/lock-free-algorithms-choosing-a-unique-value-warm-up\/"},"modified":"2011-04-05T07:00:00","modified_gmt":"2011-04-05T07:00:00","slug":"lock-free-algorithms-choosing-a-unique-value-warm-up","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110405-00\/?p=11033","title":{"rendered":"Lock-free algorithms: Choosing a unique value (warm-up)"},"content":{"rendered":"<p>\nHere&#8217;s a snippet of code whose job is to generate a unique number\nwithin the process.\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2004\/09\/15\/229915.aspx\">\nHere&#8217;s some reference reading to get yourself in the mood<\/a>.\nCaution: It may or may not be useful.\n<\/p>\n<blockquote CLASS=\"m\">\n<pre>\ndwUniqueId = InterlockedCompareExchange(&amp;g_dwUniqueId,\n                                        g_dwUniqueId+1,\n                                        g_dwUniqueId);\n<\/pre>\n<\/blockquote>\n<p>\nCriticize this code fragment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a snippet of code whose job is to generate a unique number within the process. Here&#8217;s some reference reading to get yourself in the mood. Caution: It may or may not be useful. dwUniqueId = InterlockedCompareExchange(&amp;g_dwUniqueId, g_dwUniqueId+1, g_dwUniqueId); Criticize this code fragment.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-11033","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Here&#8217;s a snippet of code whose job is to generate a unique number within the process. Here&#8217;s some reference reading to get yourself in the mood. Caution: It may or may not be useful. dwUniqueId = InterlockedCompareExchange(&amp;g_dwUniqueId, g_dwUniqueId+1, g_dwUniqueId); Criticize this code fragment.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/11033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=11033"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/11033\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=11033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=11033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=11033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}