7.2.6. 非同期メッセージ送信の例
以下のコードは、送信者のプロパティーを使用して非同期送信操作を管理する方法を示しています。送信側が容量にある場合の同期ブロックを回避するオプションです。
- C++
sender.setCapacity(MY_CAPACITY); // Later bool resend = true; while (resend) { if (sender.getAvailable()>0) { sender.send(message,false); resend = false; } else { // May wish to do nothing here // or send to log file std::cout << "Warning: Capacity \ full. Retry" << std::endl; } } // Later if (sender.getUnsettled()) { session.sync(); }
- python
snd.capacity = MY_CAPACITY # Later resend = True while (resend): if (snd.available()>0): snd.send(msg, sync = False) resend = False else: print "Warning: Capacity full" # Later if (snd.unsettled()): ssn.sync()