Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
.TH "event2/event.h" 3 "Tue Jan 31 2017" "libevent" \" -*- nroff -*-
.ad l
.nh
.SH NAME
event2/event.h \- Core functions for waiting for and receiving events, and using event bases\&.  

.SH SYNOPSIS
.br
.PP
\fC#include <event2/visibility\&.h>\fP
.br
\fC#include <event2/event\-config\&.h>\fP
.br
\fC#include <stdio\&.h>\fP
.br
\fC#include <event2/util\&.h>\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBevent\fP"
.br
.RI "\fIStructure to represent a single event\&. \fP"
.ti -1c
.RI "struct \fBevent_base\fP"
.br
.RI "\fIStructure to hold information and state for a Libevent dispatch loop\&. \fP"
.ti -1c
.RI "struct \fBevent_config\fP"
.br
.RI "\fIConfiguration for an \fBevent_base\fP\&. \fP"
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fB_EVENT_LOG_DEBUG\fP   EVENT_LOG_DEBUG"
.br
.ti -1c
.RI "#define \fB_EVENT_LOG_ERR\fP   EVENT_LOG_ERR"
.br
.ti -1c
.RI "#define \fB_EVENT_LOG_MSG\fP   EVENT_LOG_MSG"
.br
.ti -1c
.RI "#define \fB_EVENT_LOG_WARN\fP   EVENT_LOG_WARN"
.br
.ti -1c
.RI "#define \fBEVENT_DBG_ALL\fP   0xffffffffu"
.br
.ti -1c
.RI "#define \fBEVENT_DBG_NONE\fP   0"
.br
.ti -1c
.RI "#define \fBevent_get_signal\fP(ev)   ((int)\fBevent_get_fd\fP(ev))"
.br
.RI "\fIGet the signal number assigned to a signal event\&. \fP"
.ti -1c
.RI "#define \fBEVENT_MAX_PRIORITIES\fP   256"
.br
.RI "\fILargest number of priorities that Libevent can support\&. \fP"
.ti -1c
.RI "#define \fBEVENT_SET_MEM_FUNCTIONS_IMPLEMENTED\fP"
.br
.RI "\fIThis definition is present if Libevent was built with support for \fBevent_set_mem_functions()\fP \fP"
.ti -1c
.RI "#define \fBLIBEVENT_VERSION\fP   EVENT__VERSION"
.br
.RI "\fIAs event_get_version, but gives the version of Libevent's headers\&. \fP"
.ti -1c
.RI "#define \fBLIBEVENT_VERSION_NUMBER\fP   EVENT__NUMERIC_VERSION"
.br
.RI "\fIAs event_get_version_number, but gives the version number of Libevent's headers\&. \fP"
.in -1c
.PP
.RI "\fBevent type flag\fP"
.br
Flags to pass to \fBevent_base_get_num_events()\fP to specify the kinds of events we want to aggregate counts for 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBEVENT_BASE_COUNT_ACTIVE\fP   1U"
.br
.RI "\fIcount the number of active events, which have been triggered\&. \fP"
.ti -1c
.RI "#define \fBEVENT_BASE_COUNT_VIRTUAL\fP   2U"
.br
.RI "\fIcount the number of virtual events, which is used to represent an internal condition, other than a pending event, that keeps the loop from exiting\&. \fP"
.ti -1c
.RI "#define \fBEVENT_BASE_COUNT_ADDED\fP   4U"
.br
.RI "\fIcount the number of events which have been added to event base, including internal events\&. \fP"
.in -1c
.in -1c
.PP
.RI "\fBLog severities\fP"
.br

.in +1c
.in +1c
.ti -1c
.RI "#define \fBEVENT_LOG_DEBUG\fP   0"
.br
.ti -1c
.RI "#define \fBEVENT_LOG_MSG\fP   1"
.br
.ti -1c
.RI "#define \fBEVENT_LOG_WARN\fP   2"
.br
.ti -1c
.RI "#define \fBEVENT_LOG_ERR\fP   3"
.br
.in -1c
.in -1c
.PP
.RI "\fBLoop flags\fP"
.br
These flags control the behavior of \fBevent_base_loop()\fP\&. 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBEVLOOP_ONCE\fP   0x01"
.br
.RI "\fIBlock until we have an active event, then exit once all active events have had their callbacks run\&. \fP"
.ti -1c
.RI "#define \fBEVLOOP_NONBLOCK\fP   0x02"
.br
.RI "\fIDo not block: see which events are ready now, run the callbacks of the highest-priority ones, then exit\&. \fP"
.ti -1c
.RI "#define \fBEVLOOP_NO_EXIT_ON_EMPTY\fP   0x04"
.br
.RI "\fIDo not exit the loop because we have no pending events\&. \fP"
.in -1c
.in -1c
.PP
.RI "\fBevent flags\fP"
.br
Flags to pass to \fBevent_new()\fP, \fBevent_assign()\fP, \fBevent_pending()\fP, and anything else with an argument of the form 'short events' 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBEV_TIMEOUT\fP   0x01"
.br
.RI "\fIIndicates that a timeout has occurred\&. \fP"
.ti -1c
.RI "#define \fBEV_READ\fP   0x02"
.br
.RI "\fIWait for a socket or FD to become readable\&. \fP"
.ti -1c
.RI "#define \fBEV_WRITE\fP   0x04"
.br
.RI "\fIWait for a socket or FD to become writeable\&. \fP"
.ti -1c
.RI "#define \fBEV_SIGNAL\fP   0x08"
.br
.RI "\fIWait for a POSIX signal to be raised\&. \fP"
.ti -1c
.RI "#define \fBEV_PERSIST\fP   0x10"
.br
.RI "\fIPersistent event: won't get removed automatically when activated\&. \fP"
.ti -1c
.RI "#define \fBEV_ET\fP   0x20"
.br
.RI "\fISelect edge-triggered behavior, if supported by the backend\&. \fP"
.ti -1c
.RI "#define \fBEV_FINALIZE\fP   0x40"
.br
.RI "\fIIf this option is provided, then \fBevent_del()\fP will not block in one thread while waiting for the event callback to complete in another thread\&. \fP"
.ti -1c
.RI "#define \fBEV_CLOSED\fP   0x80"
.br
.RI "\fIDetects connection close events\&. \fP"
.in -1c
.in -1c
.PP
.RI "\fBevtimer_* macros\fP"
.br
Aliases for working with one-shot timer events 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBevtimer_assign\fP(ev,  b,  cb,  arg)   \fBevent_assign\fP((ev), (b), \-1, 0, (cb), (arg))"
.br
.ti -1c
.RI "#define \fBevtimer_new\fP(b,  cb,  arg)             \fBevent_new\fP((b), \-1, 0, (cb), (arg))"
.br
.ti -1c
.RI "#define \fBevtimer_add\fP(ev,  tv)   \fBevent_add\fP((ev), (tv))"
.br
.ti -1c
.RI "#define \fBevtimer_del\fP(ev)   \fBevent_del\fP(ev)"
.br
.ti -1c
.RI "#define \fBevtimer_pending\fP(ev,  tv)   \fBevent_pending\fP((ev), \fBEV_TIMEOUT\fP, (tv))"
.br
.ti -1c
.RI "#define \fBevtimer_initialized\fP(ev)   \fBevent_initialized\fP(ev)"
.br
.in -1c
.in -1c
.PP
.RI "\fBevsignal_* macros\fP"
.br
Aliases for working with signal events 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBevsignal_add\fP(ev,  tv)   \fBevent_add\fP((ev), (tv))"
.br
.ti -1c
.RI "#define \fBevsignal_assign\fP(ev,  b,  x,  cb,  arg)   \fBevent_assign\fP((ev), (b), (x), \fBEV_SIGNAL\fP|\fBEV_PERSIST\fP, cb, (arg))"
.br
.ti -1c
.RI "#define \fBevsignal_new\fP(b,  x,  cb,  arg)   \fBevent_new\fP((b), (x), \fBEV_SIGNAL\fP|\fBEV_PERSIST\fP, (cb), (arg))"
.br
.ti -1c
.RI "#define \fBevsignal_del\fP(ev)   \fBevent_del\fP(ev)"
.br
.ti -1c
.RI "#define \fBevsignal_pending\fP(ev,  tv)   \fBevent_pending\fP((ev), \fBEV_SIGNAL\fP, (tv))"
.br
.ti -1c
.RI "#define \fBevsignal_initialized\fP(ev)   \fBevent_initialized\fP(ev)"
.br
.in -1c
.in -1c
.SS "Typedefs"

.in +1c
.ti -1c
.RI "typedef int(* \fBevent_base_foreach_event_cb\fP) (const struct \fBevent_base\fP *, const struct \fBevent\fP *, void *)"
.br
.RI "\fICallback for iterating events in an event base via event_base_foreach_event\&. \fP"
.ti -1c
.RI "typedef void(* \fBevent_callback_fn\fP) (\fBevutil_socket_t\fP, short, void *)"
.br
.RI "\fIA callback function for an event\&. \fP"
.ti -1c
.RI "typedef void(* \fBevent_fatal_cb\fP) (int err)"
.br
.RI "\fIA function to be called if Libevent encounters a fatal internal error\&. \fP"
.ti -1c
.RI "typedef void(* \fBevent_finalize_callback_fn\fP) (struct \fBevent\fP *, void *)"
.br
.RI "\fICallback type for event_finalize and event_free_finalize()\&. \fP"
.ti -1c
.RI "typedef void(* \fBevent_log_cb\fP) (int severity, const char *msg)"
.br
.RI "\fIA callback function used to intercept Libevent's log messages\&. \fP"
.in -1c
.SS "Enumerations"

.in +1c
.ti -1c
.RI "enum \fBevent_base_config_flag\fP { \fBEVENT_BASE_FLAG_NOLOCK\fP = 0x01, \fBEVENT_BASE_FLAG_IGNORE_ENV\fP = 0x02, \fBEVENT_BASE_FLAG_STARTUP_IOCP\fP = 0x04, \fBEVENT_BASE_FLAG_NO_CACHE_TIME\fP = 0x08, \fBEVENT_BASE_FLAG_EPOLL_USE_CHANGELIST\fP = 0x10, \fBEVENT_BASE_FLAG_PRECISE_TIMER\fP = 0x20 }
.RI "\fIA flag passed to \fBevent_config_set_flag()\fP\&. \fP""
.br
.ti -1c
.RI "enum \fBevent_method_feature\fP { \fBEV_FEATURE_ET\fP = 0x01, \fBEV_FEATURE_O1\fP = 0x02, \fBEV_FEATURE_FDS\fP = 0x04, \fBEV_FEATURE_EARLY_CLOSE\fP = 0x08 }
.RI "\fIA flag used to describe which features an \fBevent_base\fP (must) provide\&. \fP""
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_active\fP (struct \fBevent\fP *ev, int res, short ncalls)"
.br
.RI "\fIMake an event active\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_add\fP (struct \fBevent\fP *ev, const struct timeval *timeout)"
.br
.RI "\fIAdd an event to the set of pending events\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_assign\fP (struct \fBevent\fP *, struct \fBevent_base\fP *, \fBevutil_socket_t\fP, short, \fBevent_callback_fn\fP, void *)"
.br
.RI "\fIPrepare a new, already-allocated event structure to be added\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_base_active_by_fd\fP (struct \fBevent_base\fP *base, \fBevutil_socket_t\fP fd, short events)"
.br
.RI "\fIActivates all pending events for the given fd and event mask\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_base_active_by_signal\fP (struct \fBevent_base\fP *base, int sig)"
.br
.RI "\fIActivates all pending signals with a given signal number\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_dispatch\fP (struct \fBevent_base\fP *)"
.br
.RI "\fIEvent dispatching loop\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_base_dump_events\fP (struct \fBevent_base\fP *, FILE *)"
.br
.RI "\fIWrites a human-readable description of all inserted and/or active events to a provided stdio stream\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_foreach_event\fP (struct \fBevent_base\fP *base, \fBevent_base_foreach_event_cb\fP fn, void *arg)"
.br
.RI "\fIIterate over all added or active events events in an event loop, and invoke a given callback on each one\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_base_free\fP (struct \fBevent_base\fP *)"
.br
.RI "\fIDeallocate all memory associated with an \fBevent_base\fP, and free the base\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_base_free_nofinalize\fP (struct \fBevent_base\fP *)"
.br
.RI "\fIAs event_free, but do not run finalizers\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_get_features\fP (const struct \fBevent_base\fP *base)"
.br
.RI "\fIReturn a bitmask of the features implemented by an event base\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_get_max_events\fP (struct \fBevent_base\fP *, unsigned int, int)"
.br
.RI "\fIGet the maximum number of events in a given \fBevent_base\fP as specified in the flags\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL const char * \fBevent_base_get_method\fP (const struct \fBevent_base\fP *)"
.br
.RI "\fIGet the kernel event notification mechanism used by Libevent\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_get_npriorities\fP (struct \fBevent_base\fP *eb)"
.br
.RI "\fIGet the number of different event priorities\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_get_num_events\fP (struct \fBevent_base\fP *, unsigned int)"
.br
.RI "\fIGets the number of events in \fBevent_base\fP, as specified in the flags\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevent\fP * \fBevent_base_get_running_event\fP (struct \fBevent_base\fP *base)"
.br
.RI "\fIIf called from within the callback for an event, returns that event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_gettimeofday_cached\fP (struct \fBevent_base\fP *base, struct timeval *tv)"
.br
.RI "\fISets 'tv' to the current time (as returned by gettimeofday()), looking at the cached value in 'base' if possible, and calling gettimeofday() or clock_gettime() as appropriate if there is no cached time\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_got_break\fP (struct \fBevent_base\fP *)"
.br
.RI "\fIChecks if the event loop was told to abort immediately by \fBevent_base_loopbreak()\fP\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_got_exit\fP (struct \fBevent_base\fP *)"
.br
.RI "\fIChecks if the event loop was told to exit by \fBevent_base_loopexit()\fP\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL const struct timeval * \fBevent_base_init_common_timeout\fP (struct \fBevent_base\fP *base, const struct timeval *duration)"
.br
.RI "\fIPrepare an \fBevent_base\fP to use a large number of timeouts with the same duration\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_loop\fP (struct \fBevent_base\fP *, int)"
.br
.RI "\fIWait for events to become active, and run their callbacks\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_loopbreak\fP (struct \fBevent_base\fP *)"
.br
.RI "\fIAbort the active \fBevent_base_loop()\fP immediately\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_loopcontinue\fP (struct \fBevent_base\fP *)"
.br
.RI "\fITell the active \fBevent_base_loop()\fP to scan for new events immediately\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_loopexit\fP (struct \fBevent_base\fP *, const struct timeval *)"
.br
.RI "\fIExit the event loop after the specified time\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevent_base\fP * \fBevent_base_new\fP (void)"
.br
.RI "\fICreate and return a new \fBevent_base\fP to use with the rest of Libevent\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevent_base\fP * \fBevent_base_new_with_config\fP (const struct \fBevent_config\fP *)"
.br
.RI "\fIInitialize the event API\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_once\fP (struct \fBevent_base\fP *, \fBevutil_socket_t\fP, short, \fBevent_callback_fn\fP, void *, const struct timeval *)"
.br
.RI "\fISchedule a one-time event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_priority_init\fP (struct \fBevent_base\fP *, int)"
.br
.RI "\fISet the number of different event priorities\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_set\fP (struct \fBevent_base\fP *, struct \fBevent\fP *)"
.br
.RI "\fIAssociate a different event base with an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_base_update_cache_time\fP (struct \fBevent_base\fP *base)"
.br
.RI "\fIUpdate cached_tv in the 'base' to the current time\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_config_avoid_method\fP (struct \fBevent_config\fP *cfg, const char *method)"
.br
.RI "\fIEnters an event method that should be avoided into the configuration\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_config_free\fP (struct \fBevent_config\fP *cfg)"
.br
.RI "\fIDeallocates all memory associated with an event configuration object\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevent_config\fP * \fBevent_config_new\fP (void)"
.br
.RI "\fIAllocates a new event configuration object\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_config_require_features\fP (struct \fBevent_config\fP *cfg, int feature)"
.br
.RI "\fIEnters a required event method feature that the application demands\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_config_set_flag\fP (struct \fBevent_config\fP *cfg, int flag)"
.br
.RI "\fISets one or more flags to configure what parts of the eventual \fBevent_base\fP will be initialized, and how they'll work\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_config_set_max_dispatch_interval\fP (struct \fBevent_config\fP *cfg, const struct timeval *max_interval, int max_callbacks, int min_priority)"
.br
.RI "\fIRecord an interval and/or a number of callbacks after which the event base should check for new events\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_config_set_num_cpus_hint\fP (struct \fBevent_config\fP *cfg, int cpus)"
.br
.RI "\fIRecords a hint for the number of CPUs in the system\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_debug_unassign\fP (struct \fBevent\fP *)"
.br
.RI "\fIWhen debugging mode is enabled, informs Libevent that an event should no longer be considered as assigned\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_del\fP (struct \fBevent\fP *)"
.br
.RI "\fIRemove an event from the set of monitored events\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_del_block\fP (struct \fBevent\fP *ev)"
.br
.RI "\fIAs \fBevent_del()\fP, but always blocks while the event's callback is running in another thread, even if the event was constructed with the EV_FINALIZE flag\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_del_noblock\fP (struct \fBevent\fP *ev)"
.br
.RI "\fIAs \fBevent_del()\fP, but never blocks while the event's callback is running in another thread, even if the event was constructed without the EV_FINALIZE flag\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_enable_debug_logging\fP (ev_uint32_t which)"
.br
.RI "\fITurn on debugging logs and have them sent to the default log handler\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_enable_debug_mode\fP (void)"
.br
.RI "\fIEnable some relatively expensive debugging checks in Libevent that would normally be turned off\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_free\fP (struct \fBevent\fP *)"
.br
.RI "\fIDeallocate a struct event * returned by \fBevent_new()\fP\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_get_assignment\fP (const struct \fBevent\fP *\fBevent\fP, struct \fBevent_base\fP **base_out, \fBevutil_socket_t\fP *fd_out, short *events_out, \fBevent_callback_fn\fP *callback_out, void **arg_out)"
.br
.RI "\fIExtract \fIall\fP of arguments given to construct a given event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevent_base\fP * \fBevent_get_base\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fIGet the \fBevent_base\fP associated with an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL \fBevent_callback_fn\fP \fBevent_get_callback\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fIReturn the callback assigned to an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void * \fBevent_get_callback_arg\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fIReturn the callback argument assigned to an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL short \fBevent_get_events\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fIReturn the events (EV_READ, EV_WRITE, etc) assigned to an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL \fBevutil_socket_t\fP \fBevent_get_fd\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fIGet the socket or signal assigned to an event, or -1 if the event has no socket\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_get_priority\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fIReturn the priority of an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL size_t \fBevent_get_struct_event_size\fP (void)"
.br
.RI "\fIReturn the size of struct event that the Libevent library was compiled with\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL const char ** \fBevent_get_supported_methods\fP (void)"
.br
.RI "\fIGets all event notification mechanisms supported by Libevent\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL const char * \fBevent_get_version\fP (void)"
.br
.RI "\fIGet the Libevent version\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL ev_uint32_t \fBevent_get_version_number\fP (void)"
.br
.RI "\fIReturn a numeric representation of Libevent's version\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_gettime_monotonic\fP (struct \fBevent_base\fP *base, struct timeval *tp)"
.br
.RI "\fIQuery the current monotonic time from a the timer for a struct \fBevent_base\fP\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_initialized\fP (const struct \fBevent\fP *ev)"
.br
.RI "\fITest if an event structure might be initialized\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL struct \fBevent\fP * \fBevent_new\fP (struct \fBevent_base\fP *, \fBevutil_socket_t\fP, short, \fBevent_callback_fn\fP, void *)"
.br
.RI "\fIAllocate and asssign a new event structure, ready to be added\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_pending\fP (const struct \fBevent\fP *ev, short events, struct timeval *tv)"
.br
.RI "\fIChecks if a specific event is pending or scheduled\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_priority_set\fP (struct \fBevent\fP *, int)"
.br
.RI "\fIAssign a priority to an event\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_reinit\fP (struct \fBevent_base\fP *base)"
.br
.RI "\fIReinitialize the event base after a fork\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_remove_timer\fP (struct \fBevent\fP *ev)"
.br
.RI "\fIRemove a timer from a pending event without removing the event itself\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void * \fBevent_self_cbarg\fP (void)"
.br
.RI "\fIReturn a value used to specify that the event itself must be used as the callback argument\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_set_fatal_callback\fP (\fBevent_fatal_cb\fP cb)"
.br
.RI "\fIOverride Libevent's behavior in the event of a fatal internal error\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_set_log_callback\fP (\fBevent_log_cb\fP cb)"
.br
.RI "\fIRedirect Libevent's log messages\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBevent_set_mem_functions\fP (void *(*malloc_fn)(size_t sz), void *(*realloc_fn)(void *ptr, size_t sz), void(*free_fn)(void *ptr))"
.br
.RI "\fIOverride the functions that Libevent uses for memory management\&. \fP"
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL void \fBlibevent_global_shutdown\fP (void)"
.br
.RI "\fIRelease up all globally-allocated resources allocated by Libevent\&. \fP"
.in -1c
.PP
.RI "\fBFinalization functions\fP"
.br
These functions are used to safely tear down an event in a multithreaded application\&.
.PP
If you construct your events with EV_FINALIZE to avoid deadlocks, you will need a way to remove an event in the certainty that it will definitely not be running its callback when you deallocate it and its callback argument\&.
.PP
To do this, call one of event_finalize() or event_free_finalize with 0 for its first argument, the event to tear down as its second argument, and a callback function as its third argument\&. The callback will be invoked as part of the event loop, with the event's priority\&.
.PP
After you call a finalizer function, \fBevent_add()\fP and \fBevent_active()\fP will no longer work on the event, and \fBevent_del()\fP will produce a no-op\&. You must not try to change the event's fields with \fBevent_assign()\fP or \fBevent_set()\fP while the finalize callback is in progress\&. Once the callback has been invoked, you should treat the event structure as containing uninitialized memory\&.
.PP
The event_free_finalize() function frees the event after it's finalized; event_finalize() does not\&.
.PP
A finalizer callback must not make events pending or active\&. It must not add events, activate events, or attempt to 'resucitate' the event being finalized in any way\&.
.PP
THIS IS AN EXPERIMENTAL API\&. IT MIGHT CHANGE BEFORE THE LIBEVENT 2\&.1 SERIES BECOMES STABLE\&.
.PP
\fBReturns:\fP
.RS 4
0 on succes, -1 on failure\&. 
.RE
.PP

.PP
.in +1c
.in +1c
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_finalize\fP (unsigned, struct \fBevent\fP *, \fBevent_finalize_callback_fn\fP)"
.br
.ti -1c
.RI "EVENT2_EXPORT_SYMBOL int \fBevent_free_finalize\fP (unsigned, struct \fBevent\fP *, \fBevent_finalize_callback_fn\fP)"
.br
.in -1c
.in -1c
.SH "Detailed Description"
.PP 
Core functions for waiting for and receiving events, and using event bases\&. 


.SH "Macro Definition Documentation"
.PP 
.SS "#define EV_CLOSED   0x80"

.PP
Detects connection close events\&. You can use this to detect when a connection has been closed, without having to read all the pending data from a connection\&.
.PP
Not all backends support EV_CLOSED\&. To detect or require it, use the feature flag EV_FEATURE_EARLY_CLOSE\&. 
.SS "#define EV_ET   0x20"

.PP
Select edge-triggered behavior, if supported by the backend\&. 
.SS "#define EV_FINALIZE   0x40"

.PP
If this option is provided, then \fBevent_del()\fP will not block in one thread while waiting for the event callback to complete in another thread\&. To use this option safely, you may need to use event_finalize() or event_free_finalize() in order to safely tear down an event in a multithreaded application\&. See those functions for more information\&.
.PP
THIS IS AN EXPERIMENTAL API\&. IT MIGHT CHANGE BEFORE THE LIBEVENT 2\&.1 SERIES BECOMES STABLE\&. 
.SS "#define EV_PERSIST   0x10"

.PP
Persistent event: won't get removed automatically when activated\&. When a persistent event with a timeout becomes activated, its timeout is reset to 0\&. 
.SS "#define EV_TIMEOUT   0x01"

.PP
Indicates that a timeout has occurred\&. It's not necessary to pass this flag to event_for new()/event_assign() to get a timeout\&. 
.SS "#define EVENT_BASE_COUNT_ACTIVE   1U"

.PP
count the number of active events, which have been triggered\&. 
.SS "#define EVENT_BASE_COUNT_ADDED   4U"

.PP
count the number of events which have been added to event base, including internal events\&. 
.SS "#define EVENT_BASE_COUNT_VIRTUAL   2U"

.PP
count the number of virtual events, which is used to represent an internal condition, other than a pending event, that keeps the loop from exiting\&. 
.SS "#define EVENT_MAX_PRIORITIES   256"

.PP
Largest number of priorities that Libevent can support\&. 
.SS "#define EVLOOP_NO_EXIT_ON_EMPTY   0x04"

.PP
Do not exit the loop because we have no pending events\&. Instead, keep running until \fBevent_base_loopexit()\fP or \fBevent_base_loopbreak()\fP makes us stop\&. 
.SS "#define EVLOOP_NONBLOCK   0x02"

.PP
Do not block: see which events are ready now, run the callbacks of the highest-priority ones, then exit\&. 
.SS "#define EVLOOP_ONCE   0x01"

.PP
Block until we have an active event, then exit once all active events have had their callbacks run\&. 
.SS "#define LIBEVENT_VERSION   EVENT__VERSION"

.PP
As event_get_version, but gives the version of Libevent's headers\&. 
.SS "#define LIBEVENT_VERSION_NUMBER   EVENT__NUMERIC_VERSION"

.PP
As event_get_version_number, but gives the version number of Libevent's headers\&. 
.SH "Typedef Documentation"
.PP 
.SS "typedef void(* event_callback_fn) (\fBevutil_socket_t\fP, short, void *)"

.PP
A callback function for an event\&. It receives three arguments:
.PP
\fBParameters:\fP
.RS 4
\fIfd\fP An fd or signal 
.br
\fIevents\fP One or more EV_* flags 
.br
\fIarg\fP A user-supplied argument\&.
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_new()\fP 
.RE
.PP

.SS "typedef void(* event_fatal_cb) (int err)"

.PP
A function to be called if Libevent encounters a fatal internal error\&. 
.PP
\fBSee also:\fP
.RS 4
\fBevent_set_fatal_callback\fP 
.RE
.PP

.SS "typedef void(* event_finalize_callback_fn) (struct \fBevent\fP *, void *)"

.PP
Callback type for event_finalize and event_free_finalize()\&. THIS IS AN EXPERIMENTAL API\&. IT MIGHT CHANGE BEFORE THE LIBEVENT 2\&.1 SERIES BECOMES STABLE\&. 
.SS "typedef void(* event_log_cb) (int severity, const char *msg)"

.PP
A callback function used to intercept Libevent's log messages\&. 
.PP
\fBSee also:\fP
.RS 4
\fBevent_set_log_callback\fP 
.RE
.PP

.SH "Enumeration Type Documentation"
.PP 
.SS "enum \fBevent_base_config_flag\fP"

.PP
A flag passed to \fBevent_config_set_flag()\fP\&. These flags change the behavior of an allocated \fBevent_base\fP\&.
.PP
\fBSee also:\fP
.RS 4
\fBevent_config_set_flag()\fP, \fBevent_base_new_with_config()\fP, \fBevent_method_feature\fP 
.RE
.PP

.PP
\fBEnumerator\fP
.in +1c
.TP
\fB\fIEVENT_BASE_FLAG_NOLOCK \fP\fP
Do not allocate a lock for the event base, even if we have locking set up\&. Setting this option will make it unsafe and nonfunctional to call functions on the base concurrently from multiple threads\&. 
.TP
\fB\fIEVENT_BASE_FLAG_IGNORE_ENV \fP\fP
Do not check the EVENT_* environment variables when configuring an \fBevent_base\fP\&. 
.TP
\fB\fIEVENT_BASE_FLAG_STARTUP_IOCP \fP\fP
Windows only: enable the IOCP dispatcher at startup\&. If this flag is set then \fBbufferevent_socket_new()\fP and evconn_listener_new() will use IOCP-backed implementations instead of the usual select-based one on Windows\&. 
.TP
\fB\fIEVENT_BASE_FLAG_NO_CACHE_TIME \fP\fP
Instead of checking the current time every time the event loop is ready to run timeout callbacks, check after each timeout callback\&. 
.TP
\fB\fIEVENT_BASE_FLAG_EPOLL_USE_CHANGELIST \fP\fP
If we are using the epoll backend, this flag says that it is safe to use Libevent's internal change-list code to batch up adds and deletes in order to try to do as few syscalls as possible\&. Setting this flag can make your code run faster, but it may trigger a Linux bug: it is not safe to use this flag if you have any fds cloned by dup() or its variants\&. Doing so will produce strange and hard-to-diagnose bugs\&.
.PP
This flag can also be activated by setting the EVENT_EPOLL_USE_CHANGELIST environment variable\&.
.PP
This flag has no effect if you wind up using a backend other than epoll\&. 
.TP
\fB\fIEVENT_BASE_FLAG_PRECISE_TIMER \fP\fP
Ordinarily, Libevent implements its time and timeout code using the fastest monotonic timer that we have\&. If this flag is set, however, we use less efficient more precise timer, assuming one is present\&. 
.SS "enum \fBevent_method_feature\fP"

.PP
A flag used to describe which features an \fBevent_base\fP (must) provide\&. Because of OS limitations, not every Libevent backend supports every possible feature\&. You can use this type with \fBevent_config_require_features()\fP to tell Libevent to only proceed if your \fBevent_base\fP implements a given feature, and you can receive this type from \fBevent_base_get_features()\fP to see which features are available\&. 
.PP
\fBEnumerator\fP
.in +1c
.TP
\fB\fIEV_FEATURE_ET \fP\fP
Require an event method that allows edge-triggered events with EV_ET\&. 
.TP
\fB\fIEV_FEATURE_O1 \fP\fP
Require an event method where having one event triggered among many is [approximately] an O(1) operation\&. This excludes (for example) select and poll, which are approximately O(N) for N equal to the total number of possible events\&. 
.TP
\fB\fIEV_FEATURE_FDS \fP\fP
Require an event method that allows file descriptors as well as sockets\&. 
.TP
\fB\fIEV_FEATURE_EARLY_CLOSE \fP\fP
Require an event method that allows you to use EV_CLOSED to detect connection close without the necessity of reading all the pending data\&. Methods that do support EV_CLOSED may not be able to provide support on all kernel versions\&. 
.SH "Function Documentation"
.PP 
.SS "EVENT2_EXPORT_SYMBOL void event_active (struct \fBevent\fP * ev, int res, short ncalls)"

.PP
Make an event active\&. You can use this function on a pending or a non-pending event to make it active, so that its callback will be run by \fBevent_base_dispatch()\fP or \fBevent_base_loop()\fP\&.
.PP
One common use in multithreaded programs is to wake the thread running \fBevent_base_loop()\fP from another thread\&.
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event to make active\&. 
.br
\fIres\fP a set of flags to pass to the event's callback\&. 
.br
\fIncalls\fP an obsolete argument: this is ignored\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_add (struct \fBevent\fP * ev, const struct timeval * timeout)"

.PP
Add an event to the set of pending events\&. The function \fBevent_add()\fP schedules the execution of the event 'ev' when the condition specified by \fBevent_assign()\fP or \fBevent_new()\fP occurs, or when the time specified in timeout has elapesed\&. If atimeout is NULL, no timeout occurs and the function will only be called if a matching event occurs\&. The event in the ev argument must be already initialized by \fBevent_assign()\fP or \fBevent_new()\fP and may not be used in calls to \fBevent_assign()\fP until it is no longer pending\&.
.PP
If the event in the ev argument already has a scheduled timeout, calling \fBevent_add()\fP replaces the old timeout with the new one if tv is non-NULL\&.
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event struct initialized via \fBevent_assign()\fP or \fBevent_new()\fP 
.br
\fItimeout\fP the maximum amount of time to wait for the event, or NULL to wait forever 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_del()\fP, \fBevent_assign()\fP, \fBevent_new()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_assign (struct \fBevent\fP *, struct \fBevent_base\fP *, \fBevutil_socket_t\fP, short, \fBevent_callback_fn\fP, void *)"

.PP
Prepare a new, already-allocated event structure to be added\&. The function \fBevent_assign()\fP prepares the event structure ev to be used in future calls to \fBevent_add()\fP and \fBevent_del()\fP\&. Unlike \fBevent_new()\fP, it doesn't allocate memory itself: it requires that you have already allocated a struct event, probably on the heap\&. Doing this will typically make your code depend on the size of the event structure, and thereby create incompatibility with future versions of Libevent\&.
.PP
The easiest way to avoid this problem is just to use \fBevent_new()\fP and \fBevent_free()\fP instead\&.
.PP
A slightly harder way to future-proof your code is to use \fBevent_get_struct_event_size()\fP to determine the required size of an event at runtime\&.
.PP
Note that it is NOT safe to call this function on an event that is active or pending\&. Doing so WILL corrupt internal data structures in Libevent, and lead to strange, hard-to-diagnose bugs\&. You \fIcan\fP use event_assign to change an existing event, but only if it is not active or pending!
.PP
The arguments for this function, and the behavior of the events that it makes, are as for \fBevent_new()\fP\&.
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event struct to be modified 
.br
\fIbase\fP the event base to which ev should be attached\&. 
.br
\fIfd\fP the file descriptor to be monitored 
.br
\fIevents\fP desired events to monitor; can be EV_READ and/or EV_WRITE 
.br
\fIcallback\fP callback function to be invoked when the event occurs 
.br
\fIcallback_arg\fP an argument to be passed to the callback function
.RE
.PP
\fBReturns:\fP
.RS 4
0 if success, or -1 on invalid arguments\&.
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_new()\fP, \fBevent_add()\fP, \fBevent_del()\fP, \fBevent_base_once()\fP, \fBevent_get_struct_event_size()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_base_active_by_fd (struct \fBevent_base\fP * base, \fBevutil_socket_t\fP fd, short events)"

.PP
Activates all pending events for the given fd and event mask\&. This function activates pending events only\&. Events which have not been added will not become active\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP the \fBevent_base\fP on which to activate the events\&. 
.br
\fIfd\fP An fd to active events on\&. 
.br
\fIevents\fP One or more of EV_{READ,WRITE}\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_base_active_by_signal (struct \fBevent_base\fP * base, int sig)"

.PP
Activates all pending signals with a given signal number\&. This function activates pending events only\&. Events which have not been added will not become active\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP the \fBevent_base\fP on which to activate the events\&. 
.br
\fIfd\fP The signal to active events on\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_dispatch (struct \fBevent_base\fP *)"

.PP
Event dispatching loop\&. This loop will run the event base until either there are no more pending or active, or until something calls \fBevent_base_loopbreak()\fP or \fBevent_base_loopexit()\fP\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP or \fBevent_base_new_with_config()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, -1 if an error occurred, or 1 if we exited because no events were pending or active\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loop()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_base_dump_events (struct \fBevent_base\fP *, FILE *)"

.PP
Writes a human-readable description of all inserted and/or active events to a provided stdio stream\&. This is intended for debugging; its format is not guaranteed to be the same between libevent versions\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP An \fBevent_base\fP on which to scan the events\&. 
.br
\fIoutput\fP A stdio file to write on\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_foreach_event (struct \fBevent_base\fP * base, \fBevent_base_foreach_event_cb\fP fn, void * arg)"

.PP
Iterate over all added or active events events in an event loop, and invoke a given callback on each one\&. The callback must not call any function that modifies the event base, that modifies any event in the event base, or that adds or removes any event to the event base\&. Doing so is unsupported and will lead to undefined behavior -- likely, to crashes\&.
.PP
\fBevent_base_foreach_event()\fP holds a lock on the \fBevent_base()\fP for the whole time it's running: slow callbacks are not advisable\&.
.PP
Note that Libevent adds some events of its own to make pieces of its functionality work\&. You must not assume that the only events you'll encounter will be the ones you added yourself\&.
.PP
The callback function must return 0 to continue iteration, or some other integer to stop iterating\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP An \fBevent_base\fP on which to scan the events\&. 
.br
\fIfn\fP A callback function to receive the events\&. 
.br
\fIarg\fP An argument passed to the callback function\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if we iterated over every event, or the value returned by the callback function if the loop exited early\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_base_free (struct \fBevent_base\fP *)"

.PP
Deallocate all memory associated with an \fBevent_base\fP, and free the base\&. Note that this function will not close any fds or free any memory passed to event_new as the argument to callback\&.
.PP
If there are any pending finalizer callbacks, this function will invoke them\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP an \fBevent_base\fP to be freed 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_base_free_nofinalize (struct \fBevent_base\fP *)"

.PP
As event_free, but do not run finalizers\&. THIS IS AN EXPERIMENTAL API\&. IT MIGHT CHANGE BEFORE THE LIBEVENT 2\&.1 SERIES BECOMES STABLE\&. 
.SS "EVENT2_EXPORT_SYMBOL int event_base_get_features (const struct \fBevent_base\fP * base)"

.PP
Return a bitmask of the features implemented by an event base\&. This will be a bitwise OR of one or more of the values of event_method_feature
.PP
\fBSee also:\fP
.RS 4
\fBevent_method_feature\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_get_max_events (struct \fBevent_base\fP *, unsigned int, int)"

.PP
Get the maximum number of events in a given \fBevent_base\fP as specified in the flags\&. 
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP 
.br
\fIflags\fP a bitwise combination of the kinds of events to aggregate counts for 
.br
\fIclear\fP option used to reset the maximum count\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
the number of events specified in the flags 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL const char* event_base_get_method (const struct \fBevent_base\fP *)"

.PP
Get the kernel event notification mechanism used by Libevent\&. 
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
a string identifying the kernel event mechanism (kqueue, epoll, etc\&.) 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_get_npriorities (struct \fBevent_base\fP * eb)"

.PP
Get the number of different event priorities\&. 
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
Number of different event priorities 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_priority_init()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_get_num_events (struct \fBevent_base\fP *, unsigned int)"

.PP
Gets the number of events in \fBevent_base\fP, as specified in the flags\&. Since event base has some internal events added to make some of its functionalities work, EVENT_BASE_COUNT_ADDED may return more than the number of events you added using \fBevent_add()\fP\&.
.PP
If you pass EVENT_BASE_COUNT_ACTIVE and EVENT_BASE_COUNT_ADDED together, an active event will be counted twice\&. However, this might not be the case in future libevent versions\&. The return value is an indication of the work load, but the user shouldn't rely on the exact value as this may change in the future\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP 
.br
\fIflags\fP a bitwise combination of the kinds of events to aggregate counts for 
.RE
.PP
\fBReturns:\fP
.RS 4
the number of events specified in the flags 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL struct \fBevent\fP* event_base_get_running_event (struct \fBevent_base\fP * base)"

.PP
If called from within the callback for an event, returns that event\&. The behavior of this function is not defined when called from outside the callback function for an event\&. 
.SS "EVENT2_EXPORT_SYMBOL int event_base_gettimeofday_cached (struct \fBevent_base\fP * base, struct timeval * tv)"

.PP
Sets 'tv' to the current time (as returned by gettimeofday()), looking at the cached value in 'base' if possible, and calling gettimeofday() or clock_gettime() as appropriate if there is no cached time\&. Generally, this value will only be cached while actually processing event callbacks, and may be very inaccuate if your callbacks take a long time to execute\&.
.PP
Returns 0 on success, negative on failure\&. 
.SS "EVENT2_EXPORT_SYMBOL int event_base_got_break (struct \fBevent_base\fP *)"

.PP
Checks if the event loop was told to abort immediately by \fBevent_base_loopbreak()\fP\&. This function will return true for an \fBevent_base\fP at every point after \fBevent_base_loopbreak()\fP is called, until the event loop is next entered\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_init()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
true if \fBevent_base_loopbreak()\fP was called on this event base, or 0 otherwise 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loopbreak()\fP 
.PP
\fBevent_base_got_exit()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_got_exit (struct \fBevent_base\fP *)"

.PP
Checks if the event loop was told to exit by \fBevent_base_loopexit()\fP\&. This function will return true for an \fBevent_base\fP at every point after \fBevent_loopexit()\fP is called, until the event loop is next entered\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_init()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
true if \fBevent_base_loopexit()\fP was called on this event base, or 0 otherwise 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loopexit()\fP 
.PP
\fBevent_base_got_break()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL const struct timeval* event_base_init_common_timeout (struct \fBevent_base\fP * base, const struct timeval * duration)"

.PP
Prepare an \fBevent_base\fP to use a large number of timeouts with the same duration\&. Libevent's default scheduling algorithm is optimized for having a large number of timeouts with their durations more or less randomly distributed\&. But if you have a large number of timeouts that all have the same duration (for example, if you have a large number of connections that all have a 10-second timeout), then you can improve Libevent's performance by telling Libevent about it\&.
.PP
To do this, call this function with the common duration\&. It will return a pointer to a different, opaque timeout value\&. (Don't depend on its actual contents!) When you use this timeout value in \fBevent_add()\fP, Libevent will schedule the event more efficiently\&.
.PP
(This optimization probably will not be worthwhile until you have thousands or tens of thousands of events with the same timeout\&.) 
.SS "EVENT2_EXPORT_SYMBOL int event_base_loop (struct \fBevent_base\fP *, int)"

.PP
Wait for events to become active, and run their callbacks\&. This is a more flexible version of \fBevent_base_dispatch()\fP\&.
.PP
By default, this loop will run the event base until either there are no more pending or active events, or until something calls \fBevent_base_loopbreak()\fP or \fBevent_base_loopexit()\fP\&. You can override this behavior with the 'flags' argument\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP or \fBevent_base_new_with_config()\fP 
.br
\fIflags\fP any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, -1 if an error occurred, or 1 if we exited because no events were pending or active\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loopexit()\fP, \fBevent_base_dispatch()\fP, \fBEVLOOP_ONCE\fP, \fBEVLOOP_NONBLOCK\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_loopbreak (struct \fBevent_base\fP *)"

.PP
Abort the active \fBevent_base_loop()\fP immediately\&. \fBevent_base_loop()\fP will abort the loop after the next event is completed; \fBevent_base_loopbreak()\fP is typically invoked from this event's callback\&. This behavior is analogous to the 'break;' statement\&.
.PP
Subsequent invocations of \fBevent_base_loop()\fP will proceed normally\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_init()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loopexit()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_loopcontinue (struct \fBevent_base\fP *)"

.PP
Tell the active \fBevent_base_loop()\fP to scan for new events immediately\&. Calling this function makes the currently active \fBevent_base_loop()\fP start the loop over again (scanning for new events) after the current event callback finishes\&. If the event loop is not running, this function has no effect\&.
.PP
\fBevent_base_loopbreak()\fP is typically invoked from this event's callback\&. This behavior is analogous to the 'continue;' statement\&.
.PP
Subsequent invocations of event loop will proceed normally\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_init()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loopbreak()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_loopexit (struct \fBevent_base\fP *, const struct timeval *)"

.PP
Exit the event loop after the specified time\&. The next \fBevent_base_loop()\fP iteration after the given timer expires will complete normally (handling all queued events) then exit without blocking for events again\&.
.PP
Subsequent invocations of \fBevent_base_loop()\fP will proceed normally\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_init()\fP 
.br
\fItv\fP the amount of time after which the loop should terminate, or NULL to exit after running all currently active events\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_loopbreak()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL struct \fBevent_base\fP* event_base_new (void)"

.PP
Create and return a new \fBevent_base\fP to use with the rest of Libevent\&. 
.PP
\fBReturns:\fP
.RS 4
a new \fBevent_base\fP on success, or NULL on failure\&.
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_free()\fP, \fBevent_base_new_with_config()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL struct \fBevent_base\fP* event_base_new_with_config (const struct \fBevent_config\fP *)"

.PP
Initialize the event API\&. Use \fBevent_base_new_with_config()\fP to initialize a new event base, taking the specified configuration under consideration\&. The configuration object can currently be used to avoid certain event notification mechanisms\&.
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP the event configuration object 
.RE
.PP
\fBReturns:\fP
.RS 4
an initialized \fBevent_base\fP that can be used to registering events, or NULL if no event base can be created with the requested \fBevent_config\fP\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_new()\fP, \fBevent_base_free()\fP, \fBevent_init()\fP, \fBevent_assign()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_once (struct \fBevent_base\fP *, \fBevutil_socket_t\fP, short, \fBevent_callback_fn\fP, void *, const struct timeval *)"

.PP
Schedule a one-time event\&. The function \fBevent_base_once()\fP is similar to \fBevent_new()\fP\&. However, it schedules a callback to be called exactly once, and does not require the caller to prepare an event structure\&.
.PP
Note that in Libevent 2\&.0 and earlier, if the event is never triggered, the internal memory used to hold it will never be freed\&. In Libevent 2\&.1, the internal memory will get freed by \fBevent_base_free()\fP if the event is never triggered\&. The 'arg' value, however, will not get freed in either case--you'll need to free that on your own if you want it to go away\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP an \fBevent_base\fP 
.br
\fIfd\fP a file descriptor to monitor, or -1 for no fd\&. 
.br
\fIevents\fP \fBevent(s)\fP to monitor; can be any of EV_READ | EV_WRITE, or EV_TIMEOUT 
.br
\fIcallback\fP callback function to be invoked when the event occurs 
.br
\fIarg\fP an argument to be passed to the callback function 
.br
\fItimeout\fP the maximum amount of time to wait for the event\&. NULL makes an EV_READ/EV_WRITE event make forever; NULL makes an EV_TIMEOUT event succees immediately\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_priority_init (struct \fBevent_base\fP *, int)"

.PP
Set the number of different event priorities\&. By default Libevent schedules all active events with the same priority\&. However, some time it is desirable to process some events with a higher priority than others\&. For that reason, Libevent supports strict priority queues\&. Active events with a lower priority are always processed before events with a higher priority\&.
.PP
The number of different priorities can be set initially with the \fBevent_base_priority_init()\fP function\&. This function should be called before the first call to \fBevent_base_dispatch()\fP\&. The \fBevent_priority_set()\fP function can be used to assign a priority to an event\&. By default, Libevent assigns the middle priority to all events unless their priority is explicitly set\&.
.PP
Note that urgent-priority events can starve less-urgent events: after running all urgent-priority callbacks, Libevent checks for more urgent events again, before running less-urgent events\&. Less-urgent events will not have their callbacks run until there are no events more urgent than them that want to be active\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the \fBevent_base\fP structure returned by \fBevent_base_new()\fP 
.br
\fInpriorities\fP the maximum number of priorities 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_priority_set()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_set (struct \fBevent_base\fP *, struct \fBevent\fP *)"

.PP
Associate a different event base with an event\&. The event to be associated must not be currently active or pending\&.
.PP
\fBParameters:\fP
.RS 4
\fIeb\fP the event base 
.br
\fIev\fP the event 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_base_update_cache_time (struct \fBevent_base\fP * base)"

.PP
Update cached_tv in the 'base' to the current time\&. You can use this function is useful for selectively increasing the accuracy of the cached time value in 'base' during callbacks that take a long time to execute\&.
.PP
This function has no effect if the base is currently not in its event loop, or if timeval caching is disabled via EVENT_BASE_FLAG_NO_CACHE_TIME\&.
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_config_avoid_method (struct \fBevent_config\fP * cfg, const char * method)"

.PP
Enters an event method that should be avoided into the configuration\&. This can be used to avoid event mechanisms that do not support certain file descriptor types, or for debugging to avoid certain event mechanisms\&. An application can make use of multiple event bases to accommodate incompatible file descriptor types\&.
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP the event configuration object 
.br
\fImethod\fP the name of the event method to avoid 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_config_free (struct \fBevent_config\fP * cfg)"

.PP
Deallocates all memory associated with an event configuration object\&. 
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP the event configuration object to be freed\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL struct \fBevent_config\fP* event_config_new (void)"

.PP
Allocates a new event configuration object\&. The event configuration object can be used to change the behavior of an event base\&.
.PP
\fBReturns:\fP
.RS 4
an \fBevent_config\fP object that can be used to store configuration, or NULL if an error is encountered\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_new_with_config()\fP, \fBevent_config_free()\fP, \fBevent_config\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_config_require_features (struct \fBevent_config\fP * cfg, int feature)"

.PP
Enters a required event method feature that the application demands\&. Note that not every feature or combination of features is supported on every platform\&. Code that requests features should be prepared to handle the case where \fBevent_base_new_with_config()\fP returns NULL, as in: 
.PP
.nf

  event_config_require_features(cfg, EV_FEATURE_ET);
  base = event_base_new_with_config(cfg);
  if (base == NULL) {
    // We can't get edge-triggered behavior here\&.
    event_config_require_features(cfg, 0);
    base = event_base_new_with_config(cfg);
  }
.fi
.PP
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP the event configuration object 
.br
\fIfeature\fP a bitfield of one or more event_method_feature values\&. Replaces values from previous calls to this function\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_method_feature\fP, \fBevent_base_new_with_config()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_config_set_flag (struct \fBevent_config\fP * cfg, int flag)"

.PP
Sets one or more flags to configure what parts of the eventual \fBevent_base\fP will be initialized, and how they'll work\&. 
.PP
\fBSee also:\fP
.RS 4
event_base_config_flags, \fBevent_base_new_with_config()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_config_set_max_dispatch_interval (struct \fBevent_config\fP * cfg, const struct timeval * max_interval, int max_callbacks, int min_priority)"

.PP
Record an interval and/or a number of callbacks after which the event base should check for new events\&. By default, the event base will run as many events are as activated at the higest activated priority before checking for new events\&. If you configure it by setting max_interval, it will check the time after each callback, and not allow more than max_interval to elapse before checking for new events\&. If you configure it by setting max_callbacks to a value >= 0, it will run no more than max_callbacks callbacks before checking for new events\&.
.PP
This option can decrease the latency of high-priority events, and avoid priority inversions where multiple low-priority events keep us from polling for high-priority events, but at the expense of slightly decreasing the throughput\&. Use it with caution!
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP The \fBevent_base\fP configuration object\&. 
.br
\fImax_interval\fP An interval after which Libevent should stop running callbacks and check for more events, or NULL if there should be no such interval\&. 
.br
\fImax_callbacks\fP A number of callbacks after which Libevent should stop running callbacks and check for more events, or -1 if there should be no such limit\&. 
.br
\fImin_priority\fP A priority below which max_interval and max_callbacks should not be enforced\&. If this is set to 0, they are enforced for events of every priority; if it's set to 1, they're enforced for events of priority 1 and above, and so on\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_config_set_num_cpus_hint (struct \fBevent_config\fP * cfg, int cpus)"

.PP
Records a hint for the number of CPUs in the system\&. This is used for tuning thread pools, etc, for optimal performance\&. In Libevent 2\&.0, it is only on Windows, and only when IOCP is in use\&.
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP the event configuration object 
.br
\fIcpus\fP the number of cpus 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_debug_unassign (struct \fBevent\fP *)"

.PP
When debugging mode is enabled, informs Libevent that an event should no longer be considered as assigned\&. When debugging mode is not enabled, does nothing\&.
.PP
This function must only be called on a non-added event\&.
.PP
\fBSee also:\fP
.RS 4
\fBevent_enable_debug_mode()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_del (struct \fBevent\fP *)"

.PP
Remove an event from the set of monitored events\&. The function \fBevent_del()\fP will cancel the event in the argument ev\&. If the event has already executed or has never been added the call will have no effect\&.
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event struct to be removed from the working set 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_add()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_del_block (struct \fBevent\fP * ev)"

.PP
As \fBevent_del()\fP, but always blocks while the event's callback is running in another thread, even if the event was constructed with the EV_FINALIZE flag\&. THIS IS AN EXPERIMENTAL API\&. IT MIGHT CHANGE BEFORE THE LIBEVENT 2\&.1 SERIES BECOMES STABLE\&. 
.SS "EVENT2_EXPORT_SYMBOL int event_del_noblock (struct \fBevent\fP * ev)"

.PP
As \fBevent_del()\fP, but never blocks while the event's callback is running in another thread, even if the event was constructed without the EV_FINALIZE flag\&. THIS IS AN EXPERIMENTAL API\&. IT MIGHT CHANGE BEFORE THE LIBEVENT 2\&.1 SERIES BECOMES STABLE\&. 
.SS "EVENT2_EXPORT_SYMBOL void event_enable_debug_logging (ev_uint32_t which)"

.PP
Turn on debugging logs and have them sent to the default log handler\&. This is a global setting; if you are going to call it, you must call this before any calls that create an event-base\&. You must call it before any multithreaded use of Libevent\&.
.PP
Debug logs are verbose\&.
.PP
\fBParameters:\fP
.RS 4
\fIwhich\fP Controls which debug messages are turned on\&. This option is unused for now; for forward compatibility, you must pass in the constant 'EVENT_DBG_ALL' to turn debugging logs on, or 'EVENT_DBG_NONE' to turn debugging logs off\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_enable_debug_mode (void)"

.PP
Enable some relatively expensive debugging checks in Libevent that would normally be turned off\&. Generally, these checks cause code that would otherwise crash mysteriously to fail earlier with an assertion failure\&. Note that this method MUST be called before any events or event_bases have been created\&.
.PP
Debug mode can currently catch the following errors: An event is re-assigned while it is added Any function is called on a non-assigned event
.PP
Note that debugging mode uses memory to track every event that has been initialized (via event_assign, event_set, or event_new) but not yet released (via event_free or event_debug_unassign)\&. If you want to use debug mode, and you find yourself running out of memory, you will need to use event_debug_unassign to explicitly stop tracking events that are no longer considered set-up\&.
.PP
\fBSee also:\fP
.RS 4
\fBevent_debug_unassign()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_free (struct \fBevent\fP *)"

.PP
Deallocate a struct event * returned by \fBevent_new()\fP\&. If the event is pending or active, first make it non-pending and non-active\&. 
.SS "EVENT2_EXPORT_SYMBOL void event_get_assignment (const struct \fBevent\fP * event, struct \fBevent_base\fP ** base_out, \fBevutil_socket_t\fP * fd_out, short * events_out, \fBevent_callback_fn\fP * callback_out, void ** arg_out)"

.PP
Extract \fIall\fP of arguments given to construct a given event\&. The \fBevent_base\fP is copied into *base_out, the fd is copied into *fd_out, and so on\&.
.PP
If any of the '_out' arguments is NULL, it will be ignored\&. 
.SS "EVENT2_EXPORT_SYMBOL int event_get_priority (const struct \fBevent\fP * ev)"

.PP
Return the priority of an event\&. 
.PP
\fBSee also:\fP
.RS 4
\fBevent_priority_init()\fP, \fBevent_get_priority()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL size_t event_get_struct_event_size (void)"

.PP
Return the size of struct event that the Libevent library was compiled with\&. This will be NO GREATER than sizeof(struct event) if you're running with the same version of Libevent that your application was built with, but otherwise might not\&.
.PP
Note that it might be SMALLER than sizeof(struct event) if some future version of Libevent adds extra padding to the end of struct event\&. We might do this to help ensure ABI-compatibility between different versions of Libevent\&. 
.SS "EVENT2_EXPORT_SYMBOL const char** event_get_supported_methods (void)"

.PP
Gets all event notification mechanisms supported by Libevent\&. This functions returns the event mechanism in order preferred by Libevent\&. Note that this list will include all backends that Libevent has compiled-in support for, and will not necessarily check your OS to see whether it has the required resources\&.
.PP
\fBReturns:\fP
.RS 4
an array with pointers to the names of support methods\&. The end of the array is indicated by a NULL pointer\&. If an error is encountered NULL is returned\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL const char* event_get_version (void)"

.PP
Get the Libevent version\&. Note that this will give you the version of the library that you're currently linked against, not the version of the headers that you've compiled against\&.
.PP
\fBReturns:\fP
.RS 4
a string containing the version number of Libevent 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL ev_uint32_t event_get_version_number (void)"

.PP
Return a numeric representation of Libevent's version\&. Note that this will give you the version of the library that you're currently linked against, not the version of the headers you've used to compile\&.
.PP
The format uses one byte each for the major, minor, and patchlevel parts of the version number\&. The low-order byte is unused\&. For example, version 2\&.0\&.1-alpha has a numeric representation of 0x02000100 
.SS "EVENT2_EXPORT_SYMBOL int event_initialized (const struct \fBevent\fP * ev)"

.PP
Test if an event structure might be initialized\&. The \fBevent_initialized()\fP function can be used to check if an event has been initialized\&.
.PP
Warning: This function is only useful for distinguishing a a zeroed-out piece of memory from an initialized event, it can easily be confused by uninitialized memory\&. Thus, it should ONLY be used to distinguish an initialized event from zero\&.
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event structure to be tested 
.RE
.PP
\fBReturns:\fP
.RS 4
1 if the structure might be initialized, or 0 if it has not been initialized 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL struct \fBevent\fP* event_new (struct \fBevent_base\fP *, \fBevutil_socket_t\fP, short, \fBevent_callback_fn\fP, void *)"

.PP
Allocate and asssign a new event structure, ready to be added\&. The function \fBevent_new()\fP returns a new event that can be used in future calls to \fBevent_add()\fP and \fBevent_del()\fP\&. The fd and events arguments determine which conditions will trigger the event; the callback and callback_arg arguments tell Libevent what to do when the event becomes active\&.
.PP
If events contains one of EV_READ, EV_WRITE, or EV_READ|EV_WRITE, then fd is a file descriptor or socket that should get monitored for readiness to read, readiness to write, or readiness for either operation (respectively)\&. If events contains EV_SIGNAL, then fd is a signal number to wait for\&. If events contains none of those flags, then the event can be triggered only by a timeout or by manual activation with \fBevent_active()\fP: In this case, fd must be -1\&.
.PP
The EV_PERSIST flag can also be passed in the events argument: it makes \fBevent_add()\fP persistent until \fBevent_del()\fP is called\&.
.PP
The EV_ET flag is compatible with EV_READ and EV_WRITE, and supported only by certain backends\&. It tells Libevent to use edge-triggered events\&.
.PP
The EV_TIMEOUT flag has no effect here\&.
.PP
It is okay to have multiple events all listening on the same fds; but they must either all be edge-triggered, or all not be edge triggerd\&.
.PP
When the event becomes active, the event loop will run the provided callbuck function, with three arguments\&. The first will be the provided fd value\&. The second will be a bitfield of the events that triggered: EV_READ, EV_WRITE, or EV_SIGNAL\&. Here the EV_TIMEOUT flag indicates that a timeout occurred, and EV_ET indicates that an edge-triggered event occurred\&. The third event will be the callback_arg pointer that you provide\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP the event base to which the event should be attached\&. 
.br
\fIfd\fP the file descriptor or signal to be monitored, or -1\&. 
.br
\fIevents\fP desired events to monitor: bitfield of EV_READ, EV_WRITE, EV_SIGNAL, EV_PERSIST, EV_ET\&. 
.br
\fIcallback\fP callback function to be invoked when the event occurs 
.br
\fIcallback_arg\fP an argument to be passed to the callback function
.RE
.PP
\fBReturns:\fP
.RS 4
a newly allocated struct event that must later be freed with \fBevent_free()\fP\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_free()\fP, \fBevent_add()\fP, \fBevent_del()\fP, \fBevent_assign()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_pending (const struct \fBevent\fP * ev, short events, struct timeval * tv)"

.PP
Checks if a specific event is pending or scheduled\&. 
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event struct previously passed to \fBevent_add()\fP 
.br
\fIevents\fP the requested event type; any of EV_TIMEOUT|EV_READ| EV_WRITE|EV_SIGNAL 
.br
\fItv\fP if this field is not NULL, and the event has a timeout, this field is set to hold the time at which the timeout will expire\&.
.RE
.PP
\fBReturns:\fP
.RS 4
true if the event is pending on any of the events in 'what', (that is to say, it has been added), or 0 if the event is not added\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_priority_set (struct \fBevent\fP *, int)"

.PP
Assign a priority to an event\&. 
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event struct 
.br
\fIpriority\fP the new priority to be assigned 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_priority_init()\fP, \fBevent_get_priority()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_reinit (struct \fBevent_base\fP * base)"

.PP
Reinitialize the event base after a fork\&. Some event mechanisms do not survive across fork\&. The event base needs to be reinitialized with the \fBevent_reinit()\fP function\&.
.PP
\fBParameters:\fP
.RS 4
\fIbase\fP the event base that needs to be re-initialized 
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if some events could not be re-added\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_base_new()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL int event_remove_timer (struct \fBevent\fP * ev)"

.PP
Remove a timer from a pending event without removing the event itself\&. If the event has a scheduled timeout, this function unschedules it but leaves the event otherwise pending\&.
.PP
\fBParameters:\fP
.RS 4
\fIev\fP an event struct initialized via \fBevent_assign()\fP or \fBevent_new()\fP 
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, or -1 if an error occurrect\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void* event_self_cbarg (void)"

.PP
Return a value used to specify that the event itself must be used as the callback argument\&. The function \fBevent_new()\fP takes a callback argument which is passed to the event's callback function\&. To specify that the argument to be passed to the callback function is the event that \fBevent_new()\fP returns, pass in the return value of \fBevent_self_cbarg()\fP as the callback argument for \fBevent_new()\fP\&.
.PP
For example: 
.PP
.nf

    struct event *ev = event_new(base, sock, events, callback, event_self_cbarg());
.fi
.PP
.PP
For consistency with \fBevent_new()\fP, it is possible to pass the return value of this function as the callback argument for \fBevent_assign()\fP -- this achieves the same result as passing the event in directly\&.
.PP
\fBReturns:\fP
.RS 4
a value to be passed as the callback argument to \fBevent_new()\fP or \fBevent_assign()\fP\&. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevent_new()\fP, \fBevent_assign()\fP 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void event_set_fatal_callback (\fBevent_fatal_cb\fP cb)"

.PP
Override Libevent's behavior in the event of a fatal internal error\&. By default, Libevent will call exit(1) if a programming error makes it impossible to continue correct operation\&. This function allows you to supply another callback instead\&. Note that if the function is ever invoked, something is wrong with your program, or with Libevent: any subsequent calls to Libevent may result in undefined behavior\&.
.PP
Libevent will (almost) always log an EVENT_LOG_ERR message before calling this function; look at the last log message to see why Libevent has died\&. 
.SS "EVENT2_EXPORT_SYMBOL void event_set_log_callback (\fBevent_log_cb\fP cb)"

.PP
Redirect Libevent's log messages\&. 
.PP
\fBParameters:\fP
.RS 4
\fIcb\fP a function taking two arguments: an integer severity between EVENT_LOG_DEBUG and EVENT_LOG_ERR, and a string\&. If cb is NULL, then the default log is used\&.
.RE
.PP
NOTE: The function you provide \fImust not\fP call any other libevent functionality\&. Doing so can produce undefined behavior\&. 
.SS "EVENT2_EXPORT_SYMBOL void event_set_mem_functions (void *(*)(size_t sz) malloc_fn, void *(*)(void *ptr, size_t sz) realloc_fn, void(*)(void *ptr) free_fn)"

.PP
Override the functions that Libevent uses for memory management\&. Usually, Libevent uses the standard libc functions malloc, realloc, and free to allocate memory\&. Passing replacements for those functions to \fBevent_set_mem_functions()\fP overrides this behavior\&.
.PP
Note that all memory returned from Libevent will be allocated by the replacement functions rather than by malloc() and realloc()\&. Thus, if you have replaced those functions, it will not be appropriate to free() memory that you get from Libevent\&. Instead, you must use the free_fn replacement that you provided\&.
.PP
Note also that if you are going to call this function, you should do so before any call to any Libevent function that does allocation\&. Otherwise, those funtions will allocate their memory using malloc(), but then later free it using your provided free_fn\&.
.PP
\fBParameters:\fP
.RS 4
\fImalloc_fn\fP A replacement for malloc\&. 
.br
\fIrealloc_fn\fP A replacement for realloc 
.br
\fIfree_fn\fP A replacement for free\&. 
.RE
.PP

.SS "EVENT2_EXPORT_SYMBOL void libevent_global_shutdown (void)"

.PP
Release up all globally-allocated resources allocated by Libevent\&. This function does not free developer-controlled resources like event_bases, events, bufferevents, listeners, and so on\&. It only releases resources like global locks that there is no other way to free\&.
.PP
It is not actually necessary to call this function before exit: every resource that it frees would be released anyway on exit\&. It mainly exists so that resource-leak debugging tools don't see Libevent as holding resources at exit\&.
.PP
You should only call this function when no other Libevent functions will be invoked -- e\&.g\&., when cleanly exiting a program\&. 
.SH "Author"
.PP 
Generated automatically by Doxygen for libevent from the source code\&.