<trclass="memdesc:ga0d8c3df1c0c4a3d340d8ff81355fb1e8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the Library's version. <br/></td></tr>
<trclass="memdesc:ga5fbbaa19b0290b654d2669a05bd512e8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the Library's version as a number. <br/></td></tr>
<trclass="memdesc:ga8c2ad4df801bd9d11564587ed3a7081e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Check that the header is compatible with the library. <br/></td></tr>
<trclass="memdesc:gaa3c10ba3ae001595007ad0dc5dccc15e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Gives the current time in milliseconds. <br/></td></tr>
<trclass="memdesc:gacf5e423920d6a647df3bbf7de39d5223"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Gives the current time in nanoseconds. <br/></td></tr>
<trclass="memdesc:gad5040264cd4b1404956babf3c03a4f09"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sleeps for a given number of milliseconds. <br/></td></tr>
<trclass="memdesc:gadecfd49a58b581dbba40da77b195fd85"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the calling thread's last known error. <br/></td></tr>
<trclass="memdesc:gaca24172e1b97ca01cee29ca437f5702e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the calling thread's last known error stack. <br/></td></tr>
<trclass="memdesc:ga5fab3b18c4fe3630254483575f6066f4"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Prints the calling thread's last known error stack into the file. <br/></td></tr>
<trclass="memdesc:gab21e94ce7a7d226611ea2c05914cf19d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the maximum size of the global message delivery thread pool. <br/></td></tr>
<trclass="memdesc:gafe171baefa00a85b77205116e9f3e48a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Release thread-local memory possibly allocated by the library. <br/></td></tr>
<trclass="memdesc:gaf781f246e2e0ab24623ca667c48dc3ba"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Signs a given text using the provided private key. <br/></td></tr>
<trclass="memdesc:gaf75bb5b38bf32e6a8f43e54068625903"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Tear down the library and wait for all resources to be released. <br/></td></tr>
<p>It is invoked automatically when creating a connection, using a default spin count. However, you can call this explicitly before creating the very first connection in order for your chosen spin count to take effect.</p>
<dlclass="section warning"><dt>Warning</dt><dd>You must not call <aclass="el"href="group__library_group.html#ga4a26d4caecb23348f6eee862c95fee7d"title="Initializes the library.">nats_Open</a> and <aclass="el"href="group__library_group.html#gae75131e0ce4e5b89d0f82ea7892f112e"title="Tear down the library.">nats_Close</a> concurrently.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">lockSpinCount</td><td>The number of times the library will spin trying to lock a mutex object. </td></tr>
<p>The version of the header you used to compile your application may be incompatible with the library the application is linked with.</p>
<p>This function will check that the two are compatibles. If they are not, a message is printed and the application will exit.</p>
<dlclass="section return"><dt>Returns</dt><dd><code>true</code> if the header and library are compatibles, otherwise the application exits.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__library_group.html#ga0d8c3df1c0c4a3d340d8ff81355fb1e8"title="Returns the Library's version.">nats_GetVersion</a></dd>
<dd>
<aclass="el"href="group__library_group.html#ga5fbbaa19b0290b654d2669a05bd512e8"title="Returns the Library's version as a number.">nats_GetVersionNumber</a></dd></dl>
<p>Returns the calling thread's last known error. This can be useful when <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect</a> fails. Since no connection object is returned, you would not be able to call <aclass="el"href="group__conn_mgt_group.html#gab6cfa9cb6857ae10f096a94f5e244e63"title="Gets the last connection error.">natsConnection_GetLastError</a>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">status</td><td>if not <code>NULL</code>, this function will store the last error status in there. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>the thread local error string.</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>Do not free the string returned by this function. </dd></dl>
<p>Copies the calling thread's last known error stack into the provided buffer. If the buffer is not big enough, <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a317fb9be1a80f6b1877f96a9a2db16ad"title="A buffer is not large enough to accommodate the data.">NATS_INSUFFICIENT_BUFFER</a> is returned.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">buffer</td><td>the buffer into the stack is copied. </td></tr>
<tr><tdclass="paramname">bufLen</td><td>the size of the buffer </td></tr>
<p>This call prints the calling thread's last known error stack into the file <code>file</code>. It first prints the error status and the error string, then the stack.</p>
<p>Normally, each asynchronous subscriber that is created has its own message delivery thread. The advantage is that it reduces lock contentions, therefore improving performance.<br/>
However, if an application creates many subscribers, this is not scaling well since the process would use too many threads.</p>
<p>The library has a thread pool that can perform message delivery. If a connection is created with the proper option set (<aclass="el"href="group__opts_group.html#gabf060c92648b50c069f0abe7cbb06f1c"title="Switch on/off the use of a central message delivery thread pool.">natsOptions_UseGlobalMessageDelivery</a>), then this thread pool will be responsible for delivering the messages. The thread pool is lazily initialized, that is, no thread is used as long as no subscriber (requiring global message delivery) is created.</p>
<p>Each subscriber will be attached to a given worker on the pool so that message delivery order is guaranteed.</p>
<p>This call allows you to set the maximum size of the pool.</p>
<dlclass="section note"><dt>Note</dt><dd>At this time, a pool does not shrink, but the caller will not get an error when calling this function with a size smaller than the current size.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#gabf060c92648b50c069f0abe7cbb06f1c"title="Switch on/off the use of a central message delivery thread pool.">natsOptions_UseGlobalMessageDelivery()</a></dd>
<p>This needs to be called on user-created threads where NATS calls are performed. This does not need to be called in threads created by the library. For instance, do not call this function in the message handler that you specify when creating a subscription.</p>
<p>Also, you do not need to call this in an user thread (or the main) if you are calling <aclass="el"href="group__library_group.html#gae75131e0ce4e5b89d0f82ea7892f112e"title="Tear down the library.">nats_Close()</a> there. </p>
<p>The key is the encoded string representation of the private key, or seed. This is what you get when generating an NKey using NATS tooling.</p>
<p>The input is a string, generally the nonce sent by the server when accepting a connection.</p>
<p>This function signs the input and returns the signature through the output arguments. This call allocates memory necessary to hold the signature. If this is used as part of the signature callback passed to <aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a>, then the memory will be automatically freed by the library after the signature has been inserted in the CONNECT protocol. If this function is used outside of this context, it is the user responsibility to free the allocated memory when no longer needed.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">encodedSeed</td><td>the string encoded private key, also known as seed. </td></tr>
<tr><tdclass="paramname">input</td><td>the input to be signed. </td></tr>
<tr><tdclass="paramname">signature</td><td>the memory location of allocated memory containing the signed input. </td></tr>
<tr><tdclass="paramname">signatureLength</td><td>the size of the allocated signature. </td></tr>
<p>For this to take effect, all NATS objects that you have created must first be destroyed.</p>
<p>This call does not block and it is possible that the library is not unloaded right away if there are still internal threads referencing it, so calling <aclass="el"href="group__library_group.html#ga4a26d4caecb23348f6eee862c95fee7d"title="Initializes the library.">nats_Open()</a> right away may fail. If you want to ensure that the library is fully unloaded, call <aclass="el"href="group__library_group.html#gaf75bb5b38bf32e6a8f43e54068625903"title="Tear down the library and wait for all resources to be released.">nats_CloseAndWait()</a> instead.</p>
<dlclass="section note"><dt>Note</dt><dd>There are still a small number of thread local keys and a mutex that are not freed until the application exit (in which case a final cleanup is executed).</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>You must not call <aclass="el"href="group__library_group.html#ga4a26d4caecb23348f6eee862c95fee7d"title="Initializes the library.">nats_Open</a> and <aclass="el"href="group__library_group.html#gae75131e0ce4e5b89d0f82ea7892f112e"title="Tear down the library.">nats_Close</a> concurrently.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__library_group.html#gaf75bb5b38bf32e6a8f43e54068625903"title="Tear down the library and wait for all resources to be released.">nats_CloseAndWait()</a></dd></dl>
<p>Similar to <aclass="el"href="group__library_group.html#gae75131e0ce4e5b89d0f82ea7892f112e"title="Tear down the library.">nats_Close()</a> except that this call will make sure that all references to the library are decremented before returning (up to the given timeout). Internal threads (such as subscriptions dispatchers, etc..) hold a reference to the library. Only when all references have been released that this call will return. It means that you must call all the "destroy" calls before calling this function, otherwise it will block forever (or up to given timeout).</p>
<p>For instance, this code would "deadlock": </p><divclass="fragment"><divclass="line">natsConnection_ConnectTo(&nc, NATS_DEFAULT_URL);</div>
</div><!-- fragment --><p> But this would work as expected: </p><divclass="fragment"><divclass="line">natsConnection_ConnectTo(&nc, NATS_DEFAULT_URL);</div>
</div><!-- fragment --><p> The library and other objects (such as connections, subscriptions, etc) use internal threads. After the destroy call, it is possible or even likely that some threads are still running, holding references to the library. Unlike <aclass="el"href="group__library_group.html#gae75131e0ce4e5b89d0f82ea7892f112e"title="Tear down the library.">nats_Close()</a>, which will simply ensure that the library is ultimately releasing memory, the <aclass="el"href="group__library_group.html#gaf75bb5b38bf32e6a8f43e54068625903"title="Tear down the library and wait for all resources to be released.">nats_CloseAndWait()</a> API will ensure that all those internal threads have unrolled and that the memory used by the library is released before returning.</p>
<dlclass="section note"><dt>Note</dt><dd>If a timeout is specified, the call may return <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80ab88994c9ea9889ac4d9d656d62f550ed">NATS_TIMEOUT</a> but the library is still being tear down and memory will be released. The error is just to notify you that the operation did not complete in the allotted time. Calling <aclass="el"href="group__library_group.html#ga4a26d4caecb23348f6eee862c95fee7d"title="Initializes the library.">nats_Open()</a> in this case (or any implicit opening of the library) may result in an error since the library may still be in the process of being closed.</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>Due to the blocking nature it is illegal to call this from any NATS thread (such as message or connection callbacks). If trying to do so, a <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a9bb78b4f245d2870040d25c450febd4b">NATS_ILLEGAL_STATE</a> error will be returned.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__library_group.html#gae75131e0ce4e5b89d0f82ea7892f112e"title="Tear down the library.">nats_Close()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">timeout</td><td>the maximum time to wait for the library to be closed. If negative or 0, waits for as long as needed. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<ul>
<liclass="footer">NATS.IO Supported By Synadia Communications Inc.