µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::posix::net_stack_lockable< T, L > Class Template Reference

#include <net-stack.h>

+ Inheritance diagram for os::posix::net_stack_lockable< T, L >:

Public Types

using lockable_type = L
 
using value_type = T
 

Public Member Functions

Constructors & Destructor
template<typename... Args>
 net_stack_lockable (const char *name, net_interface &interface, lockable_type &locker, Args &&... args)
 
virtual ~net_stack_lockable ()
 
Public Member Functions
value_typeimpl (void) const
 

Public Static Member Functions

using deferred_sockets_list_t = utils::intrusive_list< class socket, utils::double_list_links, &socket::deferred_links_ >
 
virtual class socketsocket (int domain, int type, int protocol)
 
const char * name (void) const
 
void add_deferred_socket (class socket *sock)
 
deferred_sockets_list_tdeferred_sockets_list (void)
 
template<typename T >
T * allocate_socket (void)
 
template<typename T , typename L >
T * allocate_socket (L &locker)
 
net_interfaceinterface (void) const
 

Detailed Description

template<typename T, typename L>
class os::posix::net_stack_lockable< T, L >

Definition at line 361 of file net-stack.h.

Member Typedef Documentation

◆ deferred_sockets_list_t

Definition at line 132 of file net-stack.h.

◆ lockable_type

template<typename T , typename L >
using os::posix::net_stack_lockable< T, L >::lockable_type = L

Definition at line 367 of file net-stack.h.

◆ value_type

template<typename T , typename L >
using os::posix::net_stack_lockable< T, L >::value_type = T

Definition at line 366 of file net-stack.h.

Constructor & Destructor Documentation

◆ net_stack_lockable()

template<typename T , typename L >
template<typename... Args>
os::posix::net_stack_lockable< T, L >::net_stack_lockable ( const char *  name,
net_interface interface,
lockable_type locker,
Args &&...  args 
)

Definition at line 595 of file net-stack.h.

599 : net_stack{ impl_instance_, name }, //
600 impl_instance_{ interface, locker, std::forward<Args> (args)... }
601 {
602#if defined(OS_TRACE_POSIX_IO_NET_STACK)
603 trace::printf ("net_stack_lockable::%s()=%p\n", __func__, this);
604#endif
605 }
net_stack(net_stack_impl &impl, const char *name)
Definition net-stack.cpp:81
net_interface & interface(void) const
const char * name(void) const
Definition net-stack.h:450
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References os::trace::printf().

◆ ~net_stack_lockable()

template<typename T , typename L >
os::posix::net_stack_lockable< T, L >::~net_stack_lockable
virtual

Definition at line 608 of file net-stack.h.

609 {
610#if defined(OS_TRACE_POSIX_IO_NET_STACK)
611 trace::printf ("net_stack_lockable::%s() @%p\n", __func__, this);
612#endif
613 }

References os::trace::printf().

Member Function Documentation

◆ add_deferred_socket()

void os::posix::net_stack::add_deferred_socket ( class socket sock)
inlineinherited

Definition at line 469 of file net-stack.h.

470 {
471 deferred_sockets_list_.link (*sock);
472 }

◆ allocate_socket() [1/2]

template<typename T , typename L >
T * os::posix::net_stack::allocate_socket ( L &  locker)
inherited

Definition at line 518 of file net-stack.h.

519 {
520 using socket_type = T;
521
522 socket_type* sock;
523
524 if (deferred_sockets_list_.empty ())
525 {
526 sock = new socket_type (*this, locker);
527 }
528 else
529 {
530 sock = static_cast<socket_type*> (
531 deferred_sockets_list_.unlink_head ());
532
533 // Call the constructor before reusing the object,
534 sock->~socket_type ();
535
536 // Placement new, run only the constructor.
537 new (sock) socket_type (*this, locker);
538
539 // Deallocate all remaining elements in the list.
540 while (!deferred_sockets_list_.empty ())
541 {
542 socket_type* s = static_cast<socket_type*> (
543 deferred_sockets_list_.unlink_head ());
544
545 // Call the destructor and the deallocator.
546 delete s;
547 }
548 }
549 return sock;
550 }

◆ allocate_socket() [2/2]

template<typename T >
T * os::posix::net_stack::allocate_socket ( void  )
inherited

Definition at line 482 of file net-stack.h.

483 {
484 using socket_type = T;
485
486 socket_type* sock;
487
488 if (deferred_sockets_list_.empty ())
489 {
490 sock = new socket_type (*this);
491 }
492 else
493 {
494 sock = static_cast<socket_type*> (
495 deferred_sockets_list_.unlink_head ());
496
497 // Call the constructor before reusing the object,
498 sock->~socket_type ();
499
500 // Placement new, run only the constructor.
501 new (sock) socket_type (*this);
502
503 // Deallocate all remaining elements in the list.
504 while (!deferred_sockets_list_.empty ())
505 {
506 socket_type* s = static_cast<socket_type*> (
507 deferred_sockets_list_.unlink_head ());
508
509 // Call the destructor and the deallocator.
510 delete s;
511 }
512 }
513 return sock;
514 }

◆ deferred_sockets_list()

net_stack::deferred_sockets_list_t & os::posix::net_stack::deferred_sockets_list ( void  )
inlineinherited

Definition at line 475 of file net-stack.h.

476 {
477 return deferred_sockets_list_;
478 }

◆ impl()

template<typename T , typename L >
net_stack_lockable< T, L >::value_type & os::posix::net_stack_lockable< T, L >::impl ( void  ) const

Definition at line 619 of file net-stack.h.

620 {
621 return static_cast<value_type&> (impl_);
622 }

◆ interface()

net_interface & os::posix::net_stack::interface ( void  ) const
inherited

◆ name()

const char * os::posix::net_stack::name ( void  ) const
inlineinherited

Definition at line 450 of file net-stack.h.

451 {
452 return name_;
453 }

◆ socket()

class socket * os::posix::net_stack::socket ( int  domain,
int  type,
int  protocol 
)
virtualinherited

Definition at line 104 of file net-stack.cpp.

105 {
106 errno = 0;
107
108 return impl ().do_socket (domain, type, protocol);
109 }
virtual class socket * do_socket(int domain, int type, int protocol)=0
net_stack_impl & impl(void) const
Definition net-stack.h:456

References os::posix::net_stack_impl::do_socket(), and os::posix::net_stack::impl().

Referenced by os::posix::socket().


The documentation for this class was generated from the following file: