c/c++ 关于变量重复定义 inet_addr it->s_str() == (*it).c_str()

来源:互联网 发布:java程序员的晋升之路 编辑:程序博客网 时间:2024/05/21 13:58

extern

static

IPC Read/Write Lock pthread_rwlock_

 

读写锁

1、             函数列表

Ø       int pthread_rwlock_rdlock(pthread_rwlock_t*rwlock);

intpthread_rwlock_wrlock(pthread_rwlock_t *rwlock);

intpthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);

intpthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);

int pthread_rwlock_unlock(pthread_rwlock_t*rwlock);

此函数获取一个读出锁,如果对应的读出锁已由某个写入者持有,那就阻塞调用线程;

此函数获取一个写入锁,如果对应的读写锁已由另一个写入者持有,或者已由一个或多个读出者持有,那就阻塞调用线程;

此二函数尝试获取一个读出锁或写入锁,但是如果该锁不能马上取得,那就返回一个EBUSY错误,而不是把调用线程投入睡眠。

此函数对读写锁进行解锁。

Ø        intpthread_rwlock_init(pthread_rwlock_t *restrict rwlock,

              const pthread_rwlockattr_t *restrictattr);

PTHREAD_RWLOCK_INITIALIZER

int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);

动态和静态初始化读写锁;

销毁读写锁。

Ø        intpthread_rwlockattr_init(pthread_rwlockattr_t *attr);

intpthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);

初始化和销毁读写锁属性变量。

Ø        intpthread_rwlockattr_getpshared(const pthread_rwlockattr_t *

             restrict attr, int *restrict pshared);

intpthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,

             int pshared);

获得读写锁属性变量具体值。

Ø        int pthread_cancel(pthread_tthread);

void pthread_cleanup_pop(int execute);

void pthread_cleanup_push(void (*routine)(void*), void *arg);

线程取消函数

inet_addr


      1 #include <iostream>
      2 #include <arpa/inet.h>
      3 #include <list>
      4 using namespace std;
      5 int main()
      6 {
      7 cout<<"main()"<<endl;
      8
      9 int n = inet_addr("1.0.0.0");
     10
     11 cout<<"n = "<<n<<endl;
     12
     13 list <string> a;
     14 a.push_back ("127.0.0.1");
     15 list <string>::iterator it;
     16
     17 for (it=a.begin(); it!=a.end(); ++it)
     18  {   cout << " " << *it<<endl;
     19
     20 int intip = inet_addr( it->c_str() );
     21 cout<<"initip = "<<intip<<endl;
     22
     23 int intip1 = inet_addr( (*it).c_str() );
     24 cout<<"initip1 = "<<intip1<<endl;
     25 }
     26
     27 return 0;
     28 }
~

原创粉丝点击