ACE_OS::strcasecmp 大小寫比較
ACE_OS::strncasecmp n個字元大小寫比較
ACE::execname (prog1); 執行prog1程式
ACE_OS_String::strdup 字元串深拷貝
ACE_OS::uname (&uname); 擷取作業系統資訊
ACE_Copy_Disabled 非拷貝基礎類
ACE_DLL 動态庫類
ACE_Process_Options
ACE_Env_Value 環境變量類
ACE_Obstack_T
ACE_Ptr 指針類
ACE_Refcounted_Auto_Ptr 指針引用計數與auto_ptr相同
ACE_Refcounted_Auto_Ptr_Rep
ACE_Auto_Basic_Ptr
ACE_Vector 提供了STL相似的vector
ACE_ARGV main參數處理類
ACE_ARGV cl (argv);
// My own stuff.
ACE_ARGV my;
// Add to my stuff.
my.add (ACE_TEXT ("-ORBEndpoint iiop://localhost:12345"));
// Print the contents of the combined <ACE_ARGV>.
for (int i = 0; i < a.argc (); i++)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT (" (%d) %s/n"),
i,
a.argv ()[i]));
ACE_Arg_Shifter 參數構造轉換類
const int test_argc_size = 5;
int argl (test_argc_size);
const ACE_TCHAR *args[test_argc_size] = {
ACE_TEXT ("-known"),
ACE_TEXT ("-huh"),
ACE_TEXT ("-arg"),
ACE_TEXT ("-what"),
ACE_TEXT ("arg")
};
ACE_Arg_Shifter shifter (argl, args);
if (!shifter.is_anything_left ())
ACE_ERROR ((LM_ERROR, "is_anything_left() returned 0 at start./n"));
static void consume_arg (int &argc, ACE_TCHAR *argv[])
{
ACE_Arg_Shifter arg_shifter (argc, argv);
if (arg_shifter.is_anything_left ())
arg_shifter.consume_arg (1);
// Once we initialize an arg_shifter, we must iterate through it all!
while ((arg_shifter.is_anything_left ()))
arg_shifter.ignore_arg (1);
}
ACE_Get_Opt 參數選項處理類
static void
parse_args (int argc, ACE_TCHAR *argv[])
{
ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("w:n:"));
int c;
while ((c = get_opt ()) != -1)
switch (c)
{
case 'w':
n_workers = ACE_OS::atoi (get_opt.opt_arg ());
break;
case 'n':
n_iterations = ACE_OS::atoi (get_opt.opt_arg ());
break;
default:
print_usage_and_die ();
break;
}
}
ACE_Atomic_Op 原子操作類
ACE_Atomic_Op <ACE_Thread_Mutex, long> foo (5);
long result = ++foo;
result = --foo;
ACE_Auto_IncDec 自動增加計數器
ACE_Adaptive_Lock 提供統一的鎖API
ACE_SString 提供了簡單的字串操作
ACE_WString 寬字元類
ACE_TString 字元類的typedef
char operator []
char &operator []
ACE_SString substring
ACE_SString substr
u_long hash
size_t length
void rep (char *s) 替換類中的指針
int strstr
ACE_Auto_String_Free 簡單的字元串指針釋放類
get 擷取類中的指針
release 釋放指針記憶體
reset 将類中的指針置0
ACE_Tokenizer 字串分割類
char buf[30];
ACE_OS::strcpy(buf, "William/Joseph/Hagins");
ACE_Tokenizer tok (buf);
tok.delimiter ('/');
for (char *p = tok.next (); p; p = tok.next ())
cout << p << endl;
輸出
William/Joseph/Hagins
Joseph/Hagins
Hagins
UUID_Generator 唯一辨別産生器,象COM的UUID
UUID* generateUUID()
ACE_Time_Value 定時器使用方法
ACE_Time_Value wait (0,
iterations * 1000 * 100); // Wait 'iter' msec
ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;
ACE_Time_Value diff = ACE_OS::gettimeofday ();
diff = diff - tv; // tv should have been reset to time acquired
long diff_msec = diff.msec ();
// Wait a little longer each time
static long wait_secs = 3;
ACE_Time_Value wait = ACE_OS::gettimeofday ();
ACE_Time_Value begin = wait;
wait.sec (wait.sec () + wait_secs);
ACE_Auto_Event 象WIN32的事件類
ACE_Event
static void *
worker (void *)
{
for (int iterations = 1;
iterations <= n_iterations;
iterations++)
{
ACE_Time_Value wait (0,
iterations * 1000 * 100); // Wait 'iter' msec
ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;
if (evt.wait (&tv) == -1)
{
// verify that we have ETIME
ACE_ASSERT(ACE_OS::last_error() == ETIME);
++timeouts;
ACE_Time_Value diff = ACE_OS::gettimeofday ();
diff = diff - tv; // tv should have been reset to time acquired
long diff_msec = diff.msec ();
if (diff_msec > ACE_ALLOWED_SLACK)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Acquire fails time reset test/n")));
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Diff btw now and returned time: %d ms/n"),
diff.msec ()));
test_result = 1;
}
// Hold the lock for a while.
ACE_OS::sleep (ACE_Time_Value (0,
(ACE_OS::rand () % 1000) * 1000));
evt.signal ();
}
ACE_Thread::yield ();
}
return 0;
}
ACE_Auto_IncDec
typedef ACE_Atomic_Op<ACE_Thread_Mutex, int> INTERLOCKED_INT;
static INTERLOCKED_INT current_threads_in_first_section;
static INTERLOCKED_INT current_threads_in_second_section;
static void *
worker (void *)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT (" (%t) worker starting/n")));
{ // First section.
typedef ACE_Atomic_Op<ACE_Thread_Mutex, int> INTERLOCKED_INT;
static INTERLOCKED_INT current_threads_in_first_section;
ACE_Auto_IncDec<INTERLOCKED_INT> threads_in_section_auto_inc_dec
(current_threads_in_first_section);
// Wait according to the number of threads...
ACE_Time_Value pause (current_threads_in_first_section.value (),
0);
ACE_OS::sleep (pause);
}
{ // Second section.
ACE_Auto_IncDec<INTERLOCKED_INT> threads_in_section_auto_inc_dec
(current_threads_in_second_section);
// Wait according to the number of threads inside the previous
// section...
ACE_Time_Value pause (current_threads_in_first_section.value (),
0);
ACE_OS::sleep (pause);
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT (" (%t) worker exiting/n")));
return 0;
}
ACE_Profile_Timer 性能定時器
ACE_Profile_Timer timer;
ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time;
timer.start ();
timer.stop ();
timer.elapsed_time (elapsed_time);
ACE_High_Res_Timer 高精度定時器
ACE_High_Res_Timer timer;
timer.reset ();
timer.start ();
while (i--)
{
ptr = allocator.malloc (chunk_size);
allocator.free (ptr);
}
timer.stop ();
timer.elapsed_time (tc);
ACE_Base64 Base64編碼類
ACE_Date_Time 時間類
ACE_Date_Time dt;
long month = dt.month ();
long day = dt.day ();
long year = dt.year ();
long hour = dt.hour ();
long minute = dt.minute ();
long seconds = dt.second ();
long usec = dt.microsec ();
ACE_Dirent_Selector 目錄處理類
ACE_Thread_Manager 線程管理器
建立線程等待結束
ACE_Thread_Manager::instance()->spawn (wait_and_kill_dialog,m_pMainWnd);
ACE_Thread_Manager::instance()->wait();