本文整理汇总了C++中nsAutoPtr::SetUp方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoPtr::SetUp方法的具体用法?C++ nsAutoPtr::SetUp怎么用?C++ nsAutoPtr::SetUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAutoPtr
的用法示例。
在下文中一共展示了nsAutoPtr::SetUp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSocketEventTask
void
UnixSocketImpl::Connect()
{
MOZ_ASSERT(!NS_IsMainThread());
if (!mConnector) {
NS_WARNING("No connector object available!");
return;
}
if (mFd.get() < 0) {
mFd = mConnector->Create();
if (mFd.get() < 0) {
return;
}
}
int ret;
if (!mConnector->CreateAddr(false, mAddrSize, mAddr, mAddress.get())) {
NS_WARNING("Cannot create socket address!");
return;
}
ret = connect(mFd.get(), (struct sockaddr*)&mAddr, mAddrSize);
if (ret) {
#if DEBUG
LOG("Socket connect errno=%d\n", errno);
#endif
mFd.reset(-1);
nsRefPtr<OnSocketEventTask> t =
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
NS_DispatchToMainThread(t);
return;
}
if (!SetSocketFlags()) {
return;
}
if (!mConnector->SetUp(mFd)) {
NS_WARNING("Could not set up socket!");
return;
}
nsRefPtr<OnSocketEventTask> t =
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS);
NS_DispatchToMainThread(t);
SetUpIO();
}
示例2: OnSocketEventTask
void
UnixSocketImpl::Connect()
{
if(mFd.get() < 0)
{
mFd = mConnector->Create();
if (mFd.get() < 0) {
return;
}
}
int ret;
socklen_t addr_sz;
struct sockaddr addr;
mConnector->CreateAddr(false, addr_sz, &addr, mAddress.get());
ret = connect(mFd.get(), &addr, addr_sz);
if (ret) {
#if DEBUG
LOG("Socket connect errno=%d\n", errno);
#endif
mFd.reset(-1);
nsRefPtr<OnSocketEventTask> t =
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
NS_DispatchToMainThread(t);
return;
}
if (!mConnector->SetUp(mFd)) {
NS_WARNING("Could not set up socket!");
return;
}
nsRefPtr<OnSocketEventTask> t =
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS);
NS_DispatchToMainThread(t);
// Due to the fact that we've dispatched our OnConnectSuccess message before
// starting reading, we're guaranteed that any subsequent read tasks will
// happen after the object has been notified of a successful connect.
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new StartImplReadingTask(this));
}