用BCB,觉得自己像个太监!
没找到Delphi开发的工作,一公司招人,说是用D和BCB开发,结果大部份都是BCB。觉得自己像个太监,不论不类!
[解决办法]
楼主说自己是个太监,那就是个太监了;用C++BUILDER的程序员,不能正常阅读VCL源码,不能在需要的时候重构某一个VCL类,真是需要再努力了。
const int iOptmzSpinCount = 6000; // 优化临界区循环值
//---------------------------------------
class TCriticalSectionPro
{
private:
int FSpinCount;
int FProcessorNum;
protected:
TRTLCriticalSection FSection;
void __fastcall SetSpinCount(int SpinCount);
public:
__fastcall TCriticalSectionPro(int SpinCount=iOptmzSpinCount);
__fastcall ~TCriticalSectionPro(void);
void __fastcall Acquire(void){EnterCriticalSection(&FSection);}
void __fastcall Release(void){LeaveCriticalSection(&FSection);}
void __fastcall Enter(void){Acquire();}
void __fastcall Leave(void){Release();}
bool __fastcall TryEnter(void){return TryAcquire();}
bool __fastcall TryAcquire(void) {return TryEnterCriticalSection(&FSection);}
__property int ProcessorNum = {read=FProcessorNum};
__property int SpinCount = {read=FSpinCount, write=SetSpinCount};
};
//---------------------------------------
class TThreadListPro
{
private:
volatile int FCount;
TList *FList;
TCriticalSectionPro *FCriticalSection;
protected:
int __fastcall GetCapacity(void);
int __fastcall SetCapacity(int Value);
void __fastcall Lock(void){FCriticalSection->Acquire();}
void __fastcall Unlock(void){FCriticalSection->Release();}
public:
__fastcall TThreadListPro(void);
__fastcall ~TThreadListPro(void);
void __fastcall UnlockList(void){Unlock();}
TList* __fastcall LockList(void){Lock();return FList;}
int __fastcall Add(void *Item); // 返回加入项在列表的当前索引
int __fastcall Remove(void *Item); // 如成功则返回被删除项在列表的旧索引,不成功返回-1
int __fastcall IndexOf(void *Item); // 如果不存在返回-1
void __fastcall Pack(void);
void __fastcall Clear(void);
void __fastcall Delete(int Index);
void __fastcall Insert(int Index, void *Item);
void __fastcall Sort(TListSortCompare Compare);
void __fastcall Move(int CurIndex, int NewIndex);
void * __fastcall Last(void); // 如果未成功,返回NULL。
void * __fastcall First(void); // 如果未成功,返回NULL。
void * __fastcall RemoveFirst(void); // 如果未成功,返回NULL。
void * __fastcall RemoveLast(void); // 如果未成功,返回NULL。
__property int Count = {read=FCount};
__property int Capacity = {read=GetCapacity, write=SetCapacity};
};
//---------------------------------------
class THandleThread : public TThread
{
private:
friend LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
protected:
MSG FMsg; //消息结构
HWND FWndHandle; //窗口句柄(HWND = void *)
virtual void __fastcall Execute(void); //在TThread类定义为纯虚函数
virtual void __fastcall CreateObject(void); //在此函数里利用AllocateHWnd建立窗口句柄
virtual void __fastcall DestroyObject(void); //在此函数里利用DestroyWindow释放窗口句柄
virtual void __fastcall WndProc(TMessage &Message);
public:
__fastcall THandleThread(bool CreateSuspended);
__property HWND WndHandle = {read=FWndHandle, default=NULL};
};
HWND __fastcall AllocateHWnd(THandleThread *Sender); //为THandleThread建立窗口句柄
//---------------------------------------