![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Chrome代码分析
文章平均质量分 51
sundebing
这个作者很懒,什么都没留下…
展开
-
加锁基类LockImpl
chrome中的加锁基类,去掉不用的部分 #pragma once#define DISALLOW_COPY_AND_ASSIGN(TypeName) / TypeName(const TypeName&); / void operator=(const TypeName&)class LockImpl{ typedef CRITICAL_SECTION原创 2009-06-24 19:01:00 · 526 阅读 · 0 评论 -
加锁类
class Lock { public: Lock() : lock_() {} ~Lock() {} void Acquire() { lock_.Lock(); } void Release() { lock_.Unlock(); } // If the lock is not held, take it and return true. If the lock is alrea原创 2009-06-24 19:12:00 · 381 阅读 · 0 评论 -
线程间进行同一据处理
InterlockedCompareExchange InterlockedCompareExchange属于互锁函数 类似的还有下面的几个 (1) LONG InterlockedExchangeAdd ( LPLONG Addend, LONG Increment ); Addend为长整型变量的地址,Increment为想要在Addend指向的长整型变量上增原创 2009-06-24 21:05:00 · 898 阅读 · 0 评论 -
自动加锁类和自动解锁类
自动回锁类// A helper class that acquires the given Lock while the AutoLock is in scope.class AutoLock { public: explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); } ~AutoLock() {原创 2009-06-24 19:17:00 · 626 阅读 · 0 评论 -
资源释放堆栈
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.#ifndef BASE_AT_EXIT_原创 2009-06-24 19:40:00 · 1787 阅读 · 0 评论 -
源码一错误
偶然看 chrome中发现一错误 template HGLOBAL CreateGlobalData(const std::basic_string& str) { HGLOBAL data = ::GlobalAlloc(GMEM_MOVEABLE, ((str.size() + 1) * sizeof(charT))); if (data) {原创 2009-06-26 14:45:00 · 340 阅读 · 0 评论 -
获得系统的版本,包括最新的win7
enum WinVersion { WINVERSION_PRE_2000 = 0, // Not supported WINVERSION_2000 = 1, WINVERSION_XP = 2, WINVERSION_SERVER_2003 = 3, WINVERSION_VISTA = 4, WINVERSION_2008 = 5, WINVERS原创 2009-09-16 15:39:00 · 435 阅读 · 0 评论 -
实现编译期判断表达式
template struct CompileAssert {};#undef COMPILE_ASSERT#define COMPILE_ASSERT(expr, msg) / typedef CompileAssert msg[bool(expr) ? 1 : -1] 在编译期就可以出现错误,但expr应该必须是个常量,这个还没试验过,这个其实还有另一个写法原创 2009-09-24 21:50:00 · 505 阅读 · 0 评论