RADVISION H.323 Protocol Toolkit 5.5 线程模型

RADVISION H.323 Protocol Toolkit 5.5 线程模型

从 H.323 Protocol Toolkit Programmer Guide 可以获知在 VERSION 3 的时候,Toolkit 有了 ThreadSafe 的支持,
而且分成三种不同的工作模式让程序员作为编译选项进行选择。
1. Multi-threadsafe
   这个就是我们常说的 threadsafe,但是有前提条件。

   1.1 利用 cmInitialize() 创建 stack instance 的线程要和这个 instance 共存亡。也就是不能在利用cmEnd() 结束这个instance 前该线程终结。
   1.2 利用 cmCallNew() 创建 outgoing call 的线程也要和这些 call 共存亡。

   1.3 其他的 Conference Manager 函数可以从任何的其他 thread 调用。但是不能调用那些曾经在其他线程存在但是现在已经不存在的 call 或者 instance 的相关函数。

In this model, application code running in one thread can call a Stack instance
belonging to another thread. This is true when the following takes place:
         Using cmInitialize(), the application creates an instance of the
         Stack for a specific thread for all general functions and for
         incoming calls. This thread remains alive for the entire lifetime
         of the instance until termination, when the application calls
         cmEnd() for this instance.
         Using cmCallNew() in any thread, the application creates as
         many outgoing calls as required in one or more threads. Each
         thread must stay alive for the entire life cycle of the outgoing
         call until the call is terminated and the application calls
         cmCallClose().
         All other Conference Manager functions can be called from any
         thread provided that the application synchronizes calls to PVT/
         PST and CI functions. The application must not perform a
         function call that relates to a call that once existed in another
         thread but now no longer exists. Similarly, the application
         cannot perform a function call relating to a Stack instance that
         existed in another thread, but no longer exists.
Note You can use the multi-threadsafe model in UNIX with threads or Windows.
Use this model ONLY if you really need it, as locking and synchronization of
objects may lower performance.


   在 VERSION 4 的时候,针对 threadsafe 做了一些改进,将 PVT/PST 函数 支持 threadsafe.

THREADSAFE PVT and PST functions are now threadsafe. The application is not responsible
           for the synchronization of calls to these functions.  
  
2. Multi-instance

In this model, every thread runs a number of Stack instances. The application
cannot call Stack instances across threads. This means, from a thread you cannot
perform a function call to a Stack instance that belongs to another thread.
However, you can run multiple threads where each one has its own set of Stack
instances.
Note Use this model if performance considerations are important and you do not
need a full multi-threadsafe model. This model uses Thread Local Storage (TLS)
in Windows.


3. Non-threadsafe

In this model, all function calls to the Stack are performed from the same thread.
Note Use this model in Windows when TLS causes problems. TLS cannot be
used when the Stack DLL is dynamically loaded.

H.323 Protocol Stack Reference Guide 里面也提到有些函数必须在同一个线程里面调用。总的来看,threadsafe
的使用条条框框比较多,比较难使用。如果编码的时候忽视了某个约定,那么就可能导致代码出现异常。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值